mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-06-13 21:54:13 +08:00
Fix Android certificate initialize
This commit is contained in:
parent
c57bbcb68a
commit
44177b9e58
@ -33,16 +33,14 @@ func NewStore(ctx context.Context, logger logger.Logger, options option.Certific
|
|||||||
var systemPool *x509.CertPool
|
var systemPool *x509.CertPool
|
||||||
switch options.Store {
|
switch options.Store {
|
||||||
case C.CertificateStoreSystem, "":
|
case C.CertificateStoreSystem, "":
|
||||||
platformInterface := service.FromContext[platform.Interface](ctx)
|
|
||||||
systemCertificates := platformInterface.SystemCertificates()
|
|
||||||
if len(systemCertificates) > 0 {
|
|
||||||
systemPool = x509.NewCertPool()
|
systemPool = x509.NewCertPool()
|
||||||
for _, cert := range systemCertificates {
|
var systemValid bool
|
||||||
if !systemPool.AppendCertsFromPEM([]byte(cert)) {
|
for _, cert := range service.FromContext[platform.Interface](ctx).SystemCertificates() {
|
||||||
return nil, E.New("invalid system certificate PEM: ", cert)
|
if systemPool.AppendCertsFromPEM([]byte(cert)) {
|
||||||
|
systemValid = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
if !systemValid {
|
||||||
certPool, err := x509.SystemCertPool()
|
certPool, err := x509.SystemCertPool()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user