mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-23 20:52:15 +08:00
fix: TLS certificate pool initialize
Co-authored-by: Skyxim <noreply@skyxim.dev>
This commit is contained in:
parent
ed17478961
commit
c6fed3e97f
@ -33,10 +33,22 @@ func AddCertificate(certificate string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func initializeCertPool() {
|
||||||
|
var err error
|
||||||
|
certPool, err = x509.SystemCertPool()
|
||||||
|
if err != nil {
|
||||||
|
certPool = x509.NewCertPool()
|
||||||
|
}
|
||||||
|
for _, cert := range trustCerts {
|
||||||
|
certPool.AddCert(cert)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func ResetCertificate() {
|
func ResetCertificate() {
|
||||||
mutex.Lock()
|
mutex.Lock()
|
||||||
defer mutex.Unlock()
|
defer mutex.Unlock()
|
||||||
trustCerts = nil
|
trustCerts = nil
|
||||||
|
initializeCertPool()
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCertPool() *x509.CertPool {
|
func getCertPool() *x509.CertPool {
|
||||||
@ -49,12 +61,7 @@ func getCertPool() *x509.CertPool {
|
|||||||
if certPool != nil {
|
if certPool != nil {
|
||||||
return certPool
|
return certPool
|
||||||
}
|
}
|
||||||
certPool, err := x509.SystemCertPool()
|
initializeCertPool()
|
||||||
if err == nil {
|
|
||||||
for _, cert := range trustCerts {
|
|
||||||
certPool.AddCert(cert)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return certPool
|
return certPool
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user