mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-11-21 00:59:12 +00:00
https://github.com/XTLS/Xray-core/pull/5824#issuecomment-6796919801
32 lines
625 B
Go
32 lines
625 B
Go
//go:build windows
|
|
|
|
package tls
|
|
|
|
import (
|
|
"crypto/x509"
|
|
|
|
"github.com/xtls/xray-core/common/errors"
|
|
)
|
|
|
|
func (c *Config) getCertPool() (*x509.CertPool, error) {
|
|
if c.DisableSystemRoot {
|
|
return c.loadSelfCertPool()
|
|
}
|
|
|
|
// Windows should keep RootCAs nil for using the system CA.
|
|
if c.UseSystemCa && len(c.Certificate) == 0 {
|
|
return nil, nil
|
|
}
|
|
|
|
if len(c.Certificate) == 0 {
|
|
return loadCA(c.UseSystemCa), nil
|
|
}
|
|
pool := loadCA(c.UseSystemCa).Clone()
|
|
for _, cert := range c.Certificate {
|
|
if !pool.AppendCertsFromPEM(cert.Certificate) {
|
|
return nil, errors.New("failed to append cert")
|
|
}
|
|
}
|
|
return pool, nil
|
|
}
|