Skip to content

Commit

Permalink
support for mitm ca chain
Browse files Browse the repository at this point in the history
  • Loading branch information
rmanz committed Apr 5, 2024
1 parent f0e6940 commit 3d7cc42
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions https.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,11 @@ func (proxy *ProxyHttpServer) NewConnectDialToProxyWithMoreHandlers(https_proxy
}

func TLSConfigFromCA(ca *tls.Certificate) func(host string, ctx *ProxyCtx) (*tls.Config, error) {
ca.Certificate = [][]byte{ca.Certificate[0]}
return TLSConfigFromCANative(ca)
}

func TLSConfigFromCANative(ca *tls.Certificate) func(host string, ctx *ProxyCtx) (*tls.Config, error) {
return func(host string, ctx *ProxyCtx) (*tls.Config, error) {
var err error
var cert *tls.Certificate
Expand Down
4 changes: 3 additions & 1 deletion signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ func signHost(ca tls.Certificate, hosts []string) (cert *tls.Certificate, err er
if derBytes, err = x509.CreateCertificate(&csprng, &template, x509ca, certpriv.Public(), ca.PrivateKey); err != nil {
return
}
certBytes := [][]byte{derBytes}
certBytes = append(certBytes, ca.Certificate...)
return &tls.Certificate{
Certificate: [][]byte{derBytes, ca.Certificate[0]},
Certificate: certBytes,
PrivateKey: certpriv,
}, nil
}
Expand Down

0 comments on commit 3d7cc42

Please sign in to comment.