mirror of
https://github.com/Alexey71/opera-proxy.git
synced 2026-05-14 06:30:59 +00:00
use bundled certs for proxy endpoint
This commit is contained in:
@@ -31,6 +31,7 @@ import (
|
|||||||
se "github.com/Snawoot/opera-proxy/seclient"
|
se "github.com/Snawoot/opera-proxy/seclient"
|
||||||
|
|
||||||
_ "golang.org/x/crypto/x509roots/fallback"
|
_ "golang.org/x/crypto/x509roots/fallback"
|
||||||
|
"golang.org/x/crypto/x509roots/fallback/bundle"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -232,9 +233,8 @@ func run() int {
|
|||||||
KeepAlive: 30 * time.Second,
|
KeepAlive: 30 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
var caPool *x509.CertPool
|
caPool := x509.NewCertPool()
|
||||||
if args.caFile != "" {
|
if args.caFile != "" {
|
||||||
caPool = x509.NewCertPool()
|
|
||||||
certs, err := ioutil.ReadFile(args.caFile)
|
certs, err := ioutil.ReadFile(args.caFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
mainLogger.Error("Can't load CA file: %v", err)
|
mainLogger.Error("Can't load CA file: %v", err)
|
||||||
@@ -244,6 +244,19 @@ func run() int {
|
|||||||
mainLogger.Error("Can't load certificates from CA file")
|
mainLogger.Error("Can't load certificates from CA file")
|
||||||
return 15
|
return 15
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for c := range bundle.Roots() {
|
||||||
|
cert, err := x509.ParseCertificate(c.Certificate)
|
||||||
|
if err != nil {
|
||||||
|
mainLogger.Error("Unable to parse bundled certificate: %v", err)
|
||||||
|
return 15
|
||||||
|
}
|
||||||
|
if c.Constraint == nil {
|
||||||
|
caPool.AddCert(cert)
|
||||||
|
} else {
|
||||||
|
caPool.AddCertWithConstraint(cert, c.Constraint)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xproxy.RegisterDialerType("http", proxyFromURLWrapper)
|
xproxy.RegisterDialerType("http", proxyFromURLWrapper)
|
||||||
|
|||||||
Reference in New Issue
Block a user