2021-09-20 21:00:55 +08:00
|
|
|
//go:build windows
|
2020-11-25 19:01:53 +08:00
|
|
|
// +build windows
|
|
|
|
|
|
|
|
|
|
package tls
|
|
|
|
|
|
2026-10-10 11:16:54 +08:00
|
|
|
import (
|
|
|
|
|
"crypto/x509"
|
|
|
|
|
|
|
|
|
|
"github.com/xtls/xray-core/common/errors"
|
|
|
|
|
)
|
2020-11-25 19:01:53 +08:00
|
|
|
|
|
|
|
|
func (c *Config) getCertPool() (*x509.CertPool, error) {
|
|
|
|
|
if c.DisableSystemRoot {
|
|
|
|
|
return c.loadSelfCertPool()
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-10 11:16:54 +08:00
|
|
|
// 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
|
2020-11-25 19:01:53 +08:00
|
|
|
}
|