mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-10-12 02:25:49 +00:00
https://github.com/XTLS/Xray-core/pull/5532#issuecomment-3745598515 https://github.com/XTLS/Xray-core/pull/7098#issuecomment-6053012480 https://github.com/XTLS/Xray-core/pull/7105#issuecomment-6093006914
29 lines
514 B
Go
29 lines
514 B
Go
//go:build !windows
|
|
// +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()
|
|
}
|
|
|
|
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("append cert to root")
|
|
}
|
|
}
|
|
return pool, nil
|
|
}
|