add support for certificate chains, refs #174

This commit is contained in:
Maximilian Hils 2014-05-21 01:16:22 +02:00
parent 00fd243810
commit decb6f998a
2 changed files with 6 additions and 3 deletions

View File

@ -24,6 +24,7 @@ class ProxyConfig:
self.http_form_out = http_form_out self.http_form_out = http_form_out
self.authenticator = authenticator self.authenticator = authenticator
self.confdir = os.path.expanduser(confdir) self.confdir = os.path.expanduser(confdir)
self.ca_file = os.path.join(self.confdir, CONF_BASENAME + "-ca.pem")
self.certstore = certutils.CertStore.from_store(self.confdir, CONF_BASENAME) self.certstore = certutils.CertStore.from_store(self.confdir, CONF_BASENAME)
for spec, cert in certs: for spec, cert in certs:
self.certstore.add_cert_file(spec, cert) self.certstore.add_cert_file(spec, cert)

View File

@ -197,7 +197,8 @@ class ConnectionHandler:
cert, key, cert, key,
handle_sni=self.handle_sni, handle_sni=self.handle_sni,
cipher_list=self.config.ciphers, cipher_list=self.config.ciphers,
dhparams=self.config.certstore.dhparams dhparams=self.config.certstore.dhparams,
ca_file=self.config.ca_file
) )
def server_reconnect(self, no_ssl=False): def server_reconnect(self, no_ssl=False):
@ -260,11 +261,12 @@ class ConnectionHandler:
cert, key, cert, key,
method=SSL.TLSv1_METHOD, method=SSL.TLSv1_METHOD,
cipher_list=self.config.ciphers, cipher_list=self.config.ciphers,
dhparams=self.config.certstore.dhparams dhparams=self.config.certstore.dhparams,
ca_file=self.config.ca_file
) )
connection.set_context(new_context) connection.set_context(new_context)
# An unhandled exception in this method will core dump PyOpenSSL, so # An unhandled exception in this method will core dump PyOpenSSL, so
# make dang sure it doesn't happen. # make dang sure it doesn't happen.
except Exception, e: # pragma: no cover except Exception: # pragma: no cover
import traceback import traceback
self.log("Error in handle_sni:\r\n" + traceback.format_exc(), "error") self.log("Error in handle_sni:\r\n" + traceback.format_exc(), "error")