hello_ca.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package tlsconfig
  2. import (
  3. "crypto/tls"
  4. "crypto/x509"
  5. )
  6. const (
  7. helloKey = `
  8. -----BEGIN EC PARAMETERS-----
  9. BgUrgQQAIg==
  10. -----END EC PARAMETERS-----
  11. -----BEGIN EC PRIVATE KEY-----
  12. MIGkAgEBBDBGGfwhIJdiUiJUVIItqJjEIMmlXxsMa8TQeer47+g+cIZ466rgg8EK
  13. +Mdn6BY48GCgBwYFK4EEACKhZANiAASW//A9iDbPKg3OLkn7yJqLer32g9I5lBKR
  14. tPc/zBubQLLz9lAaYI6AOQiJXhGr5JkKmQfi1sYHK5rJITPFy4W8Et4hHLdazDZH
  15. WnEd+TStQABFUjrhtqXPWmGKcly0pOE=
  16. -----END EC PRIVATE KEY-----`
  17. helloCRT = `
  18. -----BEGIN CERTIFICATE-----
  19. MIICiDCCAg6gAwIBAgIJAJ/FfkBTtbuIMAkGByqGSM49BAEwfzELMAkGA1UEBhMC
  20. VVMxDjAMBgNVBAgMBVRleGFzMQ8wDQYDVQQHDAZBdXN0aW4xGTAXBgNVBAoMEENs
  21. b3VkZmxhcmUsIEluYy4xNDAyBgNVBAMMK0FyZ28gVHVubmVsIFNhbXBsZSBIZWxs
  22. byBTZXJ2ZXIgQ2VydGlmaWNhdGUwHhcNMTgwMzE5MjMwNTMyWhcNMjgwMzE2MjMw
  23. NTMyWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxDzANBgNVBAcMBkF1
  24. c3RpbjEZMBcGA1UECgwQQ2xvdWRmbGFyZSwgSW5jLjE0MDIGA1UEAwwrQXJnbyBU
  25. dW5uZWwgU2FtcGxlIEhlbGxvIFNlcnZlciBDZXJ0aWZpY2F0ZTB2MBAGByqGSM49
  26. AgEGBSuBBAAiA2IABJb/8D2INs8qDc4uSfvImot6vfaD0jmUEpG09z/MG5tAsvP2
  27. UBpgjoA5CIleEavkmQqZB+LWxgcrmskhM8XLhbwS3iEct1rMNkdacR35NK1AAEVS
  28. OuG2pc9aYYpyXLSk4aNXMFUwUwYDVR0RBEwwSoIJbG9jYWxob3N0ghFjbG91ZGZs
  29. YXJlZC1oZWxsb4ISY2xvdWRmbGFyZWQyLWhlbGxvhwR/AAABhxAAAAAAAAAAAAAA
  30. AAAAAAABMAkGByqGSM49BAEDaQAwZgIxAPxkdghH6y8xLMnY9Bom3Llf4NYM6yB9
  31. PD1YsaNUJTsxjTk3YY1Jsp+yzK0yUKtTZwIxAPcdvqCF2/iR9H288pCT1TgtO0a9
  32. cJL9RY1lq7DIGN37v1ZXReWaD+3hNokY8NriVg==
  33. -----END CERTIFICATE-----`
  34. )
  35. func GetHelloCertificate() (tls.Certificate, error) {
  36. return tls.X509KeyPair([]byte(helloCRT), []byte(helloKey))
  37. }
  38. func GetHelloCertificateX509() (*x509.Certificate, error) {
  39. helloCertificate, err := GetHelloCertificate()
  40. if err != nil {
  41. return nil, err
  42. }
  43. return x509.ParseCertificate(helloCertificate.Certificate[0])
  44. }