sideload ca.pem

This commit is contained in:
arm64v8a 2023-06-03 10:37:23 +09:00
parent 2349b381f4
commit 9b055391ee
5 changed files with 32 additions and 2 deletions

View File

@ -1 +1 @@
1
2

Binary file not shown.

View File

@ -1,5 +1,5 @@
if [ ! -z $ENV_NB4A ]; then
export COMMIT_SING_BOX_EXTRA="c61e8ae9d227a918e85fcd22fb36d89a0ad9a661"
export COMMIT_SING_BOX_EXTRA="1ea593f166ddb44e12ba9c7b41bcc6e73b66b550"
fi
if [ ! -z $ENV_SING_BOX_EXTRA ]; then

24
libcore/certs.go Normal file
View File

@ -0,0 +1,24 @@
package libcore
import (
"crypto/x509"
"log"
_ "unsafe" // for go:linkname
)
//go:linkname systemRoots crypto/x509.systemRoots
var systemRoots *x509.CertPool
func updateRootCACerts(pem []byte) {
x509.SystemCertPool()
roots := x509.NewCertPool()
if !roots.AppendCertsFromPEM(pem) {
log.Println("failed to append certificates from pem")
return
}
systemRoots = roots
log.Println("external ca.pem was loaded")
}
//go:linkname initSystemRoots crypto/x509.initSystemRoots
func initSystemRoots()

View File

@ -78,6 +78,12 @@ func InitCore(process, cachePath, internalAssets, externalAssets string,
outdated = "Your version is too old! Please update!! 版本太旧,请升级!"
}
// certs
pem, err := os.ReadFile(externalAssetsPath + "ca.pem")
if err == nil {
updateRootCACerts(pem)
}
// bg
if isBgProcess {
extractAssets()