Skip to content

Commit

Permalink
fixes #71, do not reuse tls.defaultTlsConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
elazarl committed Nov 26, 2014
1 parent 7e91b30 commit 2fc786d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion certs.go
Expand Up @@ -17,7 +17,7 @@ func init() {

var tlsClientSkipVerify = &tls.Config{InsecureSkipVerify: true}

var defaultTlsConfig = &tls.Config{
var defaultTLSConfig = &tls.Config{
InsecureSkipVerify: true,
}

Expand Down
7 changes: 4 additions & 3 deletions https.go
Expand Up @@ -146,7 +146,7 @@ func (proxy *ProxyHttpServer) handleHttps(w http.ResponseWriter, r *http.Request
// still handling the request even after hijacking the connection. Those HTTP CONNECT
// request can take forever, and the server will be stuck when "closed".
// TODO: Allow Server.Close() mechanism to shut down this connection as nicely as possible
tlsConfig := defaultTlsConfig
tlsConfig := defaultTLSConfig
if todo.TLSConfig != nil {
var err error
tlsConfig, err = todo.TLSConfig(host, ctx)
Expand Down Expand Up @@ -347,13 +347,14 @@ func (proxy *ProxyHttpServer) NewConnectDialToProxy(https_proxy string) func(net

func TLSConfigFromCA(ca *tls.Certificate) func(host string, ctx *ProxyCtx) (*tls.Config, error) {
return func(host string, ctx *ProxyCtx) (*tls.Config, error) {
config := defaultTlsConfig
config := *defaultTLSConfig
ctx.Logf("signing for %s", stripPort(host))
cert, err := signHost(*ca, []string{stripPort(host)})
if err != nil {
ctx.Warnf("Cannot sign host certificate with provided CA: %s", err)
return nil, err
}
config.Certificates = append(config.Certificates, cert)
return config, nil
return &config, nil
}
}

0 comments on commit 2fc786d

Please sign in to comment.