summaryrefslogtreecommitdiffhomepage
path: root/test/unit/applications
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2021-03-26 21:06:23 +0000
committerAndrei Zeliankou <zelenkov@nginx.com>2021-03-26 21:06:23 +0000
commite8577afc2126001db03d4b8ac1dd8670a2504322 (patch)
treeaf8e3416c79a17c9f44fd183bd87d6b1848b86ce /test/unit/applications
parentc093ee7ec50233feb3ff0444c91e394abee4c52a (diff)
downloadunit-e8577afc2126001db03d4b8ac1dd8670a2504322.tar.gz
unit-e8577afc2126001db03d4b8ac1dd8670a2504322.tar.bz2
Tests: SNI.
Diffstat (limited to '')
-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):