summaryrefslogtreecommitdiffhomepage
path: root/test/unit/applications/tls.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/applications/tls.py')
-rw-r--r--test/unit/applications/tls.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/test/unit/applications/tls.py b/test/unit/applications/tls.py
index b0cd5abb..490ae916 100644
--- a/test/unit/applications/tls.py
+++ b/test/unit/applications/tls.py
@@ -63,19 +63,34 @@ class TestApplicationTLS(TestApplicationProto):
return ssl.get_server_certificate(addr, ssl_version=ssl_version)
- def openssl_conf(self):
+ def openssl_conf(self, rewrite=False, alt_names=[]):
conf_path = option.temp_dir + '/openssl.conf'
- if os.path.exists(conf_path):
+ if not rewrite and os.path.exists(conf_path):
return
+ # Generates alt_names section with dns names
+ a_names = "[alt_names]\n"
+ for i, k in enumerate(alt_names, 1):
+ a_names += "DNS.%d = %s\n" % (i, k)
+
+ # Generates section for sign request extension
+ a_sec = """req_extensions = myca_req_extensions
+
+[ myca_req_extensions ]
+subjectAltName = @alt_names
+
+{a_names}""".format(a_names=a_names)
+
with open(conf_path, 'w') as f:
f.write(
"""[ req ]
default_bits = 2048
encrypt_key = no
distinguished_name = req_distinguished_name
-[ req_distinguished_name ]"""
+
+{a_sec}
+[ req_distinguished_name ]""".format(a_sec=a_sec if alt_names else "")
)
def load(self, script, name=None):