summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2022-02-15 21:43:02 +0000
committerAndrei Zeliankou <zelenkov@nginx.com>2022-02-15 21:43:02 +0000
commit170752e96fe06cbf78037ad50563d25ce5e668ec (patch)
treef89c7c2b21aecc17e8a596b12d178e04eb517aef /test
parent5857754ec75312c426b9277a34d0b3cfd237d22e (diff)
downloadunit-170752e96fe06cbf78037ad50563d25ce5e668ec.tar.gz
unit-170752e96fe06cbf78037ad50563d25ce5e668ec.tar.bz2
Tests: added test with long certificate chain.
Diffstat (limited to 'test')
-rw-r--r--test/test_tls.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/test_tls.py b/test/test_tls.py
index c4471f3f..fb28bc88 100644
--- a/test/test_tls.py
+++ b/test/test_tls.py
@@ -389,6 +389,51 @@ basicConstraints = critical,CA:TRUE"""
self.get_ssl()['status'] == 200
), 'certificate chain intermediate server'
+ def test_tls_certificate_chain_long(self, temp_dir):
+ self.load('empty')
+
+ self.generate_ca_conf()
+
+ # Minimum chain length is 3.
+ chain_length = 10
+
+ for i in range(chain_length):
+ if i == 0:
+ self.certificate('root', False)
+ elif i == chain_length - 1:
+ self.req('end')
+ else:
+ self.req('int{}'.format(i))
+
+ for i in range(chain_length - 1):
+ if i == 0:
+ self.ca(cert='root', out='int1')
+ elif i == chain_length - 2:
+ self.ca(cert='int{}'.format(chain_length - 2), out='end')
+ else:
+ self.ca(cert='int{}'.format(i), out='int{}'.format(i + 1))
+
+ for i in range(chain_length - 1, 0, -1):
+ path = temp_dir + (
+ '/end.crt' if i == chain_length - 1 else '/int{}.crt'.format(i)
+ )
+
+ with open(temp_dir + '/all.crt', 'a') as chain, open(path) as cert:
+ chain.write(cert.read())
+
+ self.set_certificate_req_context()
+
+ assert 'success' in self.certificate_load(
+ 'all', 'end'
+ ), 'certificate chain upload'
+
+ chain = self.conf_get('/certificates/all/chain')
+ assert len(chain) == chain_length - 1, 'certificate chain length'
+
+ self.add_tls(cert='all')
+
+ assert self.get_ssl()['status'] == 200, 'certificate chain long'
+
def test_tls_certificate_empty_cn(self, temp_dir):
self.certificate('root', False)