certpool_go17.go 486 B

123456789101112131415161718192021
  1. // +build go1.7
  2. package tlsconfig
  3. import (
  4. "crypto/x509"
  5. "runtime"
  6. "github.com/Sirupsen/logrus"
  7. )
  8. // SystemCertPool returns a copy of the system cert pool,
  9. // returns an error if failed to load or empty pool on windows.
  10. func SystemCertPool() (*x509.CertPool, error) {
  11. certpool, err := x509.SystemCertPool()
  12. if err != nil && runtime.GOOS == "windows" {
  13. logrus.Infof("Unable to use system certificate pool: %v", err)
  14. return x509.NewCertPool(), nil
  15. }
  16. return certpool, err
  17. }