certpool.go 373 B

12345678910111213141516
  1. package tlsconfig
  2. import (
  3. "crypto/x509"
  4. "runtime"
  5. )
  6. // SystemCertPool returns a copy of the system cert pool,
  7. // returns an error if failed to load or empty pool on windows.
  8. func SystemCertPool() (*x509.CertPool, error) {
  9. certpool, err := x509.SystemCertPool()
  10. if err != nil && runtime.GOOS == "windows" {
  11. return x509.NewCertPool(), nil
  12. }
  13. return certpool, err
  14. }