CaCerts specifies the root certificates for HTTPS connections with the CredHub server. If the OAuthStrategy is used for Auth, the root certificates will also be used for HTTPS connections with the OAuth server.
(certs ...string)
| 42 | // If the OAuthStrategy is used for Auth, the root certificates will also be used for HTTPS |
| 43 | // connections with the OAuth server. |
| 44 | func CaCerts(certs ...string) Option { |
| 45 | return func(c *CredHub) error { |
| 46 | // TODO: remove else block once x509.SystemCertPool is supported on Windows |
| 47 | // see: https://github.com/golang/go/issues/16736 |
| 48 | var pool *x509.CertPool |
| 49 | if runtime.GOOS != "windows" { |
| 50 | var err error |
| 51 | pool, err = x509.SystemCertPool() |
| 52 | if err != nil { |
| 53 | return err |
| 54 | } |
| 55 | } else { |
| 56 | pool = x509.NewCertPool() |
| 57 | } |
| 58 | c.caCerts = pool |
| 59 | |
| 60 | for _, cert := range certs { |
| 61 | ok := c.caCerts.AppendCertsFromPEM([]byte(cert)) |
| 62 | if !ok { |
| 63 | return errors.New("provided ca certs are invalid") |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | return nil |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | // SkipTLSValidation will skip root certificate verification for HTTPS. Not recommended! |
| 72 | func SkipTLSValidation(skipTLSvalidation bool) Option { |
no outgoing calls
searching dependent graphs…