config_other.go 422 B

123456789101112131415161718192021
  1. // +build !windows
  2. package tls
  3. import "crypto/x509"
  4. func (c *Config) getCertPool() *x509.CertPool {
  5. pool, err := x509.SystemCertPool()
  6. if err != nil {
  7. newError("failed to get system cert pool.").Base(err).WriteToLog()
  8. return nil
  9. }
  10. if pool != nil {
  11. for _, cert := range c.Certificate {
  12. if cert.Usage == Certificate_AUTHORITY_VERIFY {
  13. pool.AppendCertsFromPEM(cert.Certificate)
  14. }
  15. }
  16. }
  17. return pool
  18. }