Merge remote-tracking branch 'github/letsencrypt/master' into network2

This commit is contained in:
Jakub Warmuz
2015-03-25 18:52:34 +00:00
2 changed files with 28 additions and 14 deletions
+27 -13
View File
@@ -25,6 +25,23 @@ class ApacheDvsni(object):
:param str challenge_conf: location of the challenge config file :param str challenge_conf: location of the challenge config file
"""
VHOST_TEMPLATE = """\
<VirtualHost {vhost}>
ServerName {server_name}
UseCanonicalName on
SSLStrictSNIVHostCheck on
LimitRequestBody 1048576
Include {ssl_options_conf_path}
SSLCertificateFile {cert_path}
SSLCertificateKeyFile {key_path}
DocumentRoot {document_root}
</VirtualHost>
""" """
def __init__(self, configurator): def __init__(self, configurator):
self.configurator = configurator self.configurator = configurator
@@ -160,19 +177,16 @@ class ApacheDvsni(object):
ips = " ".join(str(i) for i in ip_addrs) ips = " ".join(str(i) for i in ip_addrs)
document_root = os.path.join( document_root = os.path.join(
self.configurator.config.config_dir, "dvsni_page/") self.configurator.config.config_dir, "dvsni_page/")
return ("<VirtualHost " + ips + ">{0}" # TODO: Python docs is not clear how mutliline string literal
"ServerName " + achall.nonce_domain + "{0}" # newlines are parsed on different platforms. At least on
"UseCanonicalName on{0}" # Linux (Debian sid), when source file uses CRLF, Python still
"SSLStrictSNIVHostCheck on{0}" # parses it as '\n'... c.f.:
"{0}" # https://docs.python.org/2.7/reference/lexical_analysis.html
"LimitRequestBody 1048576{0}" return self.VHOST_TEMPLATE.format(
"{0}" vhost=ips, server_name=achall.nonce_domain,
"Include " + self.configurator.parser.loc["ssl_options"] + "{0}" ssl_options_conf_path=self.configurator.parser.loc["ssl_options"],
"SSLCertificateFile " + self.get_cert_file(achall) + "{0}" cert_path=self.get_cert_file(achall), key_path=achall.key.file,
"SSLCertificateKeyFile " + achall.key.file + "{0}" document_root=document_root).replace('\n', os.linesep)
"{0}"
"DocumentRoot " + document_root + "{0}"
"</VirtualHost>{0}{0}".format(os.linesep))
def get_cert_file(self, achall): def get_cert_file(self, achall):
"""Returns standardized name for challenge certificate. """Returns standardized name for challenge certificate.
@@ -60,7 +60,7 @@ class DvsniPerformTest(util.ApacheTest):
def test_perform0(self): def test_perform0(self):
resp = self.sni.perform() resp = self.sni.perform()
self.assertTrue(resp is None) self.assertEqual(len(resp), 0)
def test_setup_challenge_cert(self): def test_setup_challenge_cert(self):
# This is a helper function that can be used for handling # This is a helper function that can be used for handling