]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
http/test_tls: add test for chain certificates
authorTomas Krizek <tomas.krizek@nic.cz>
Fri, 14 Jun 2019 14:58:40 +0000 (16:58 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Tue, 18 Jun 2019 08:02:07 +0000 (10:02 +0200)
modules/http/test_tls/tls.test.lua

index 5327e193e368b617908e080b765a7cc1f0ddd9d5..ccb6a24980a0b5ebac47ae802e2c24412db3ff52 100644 (file)
@@ -148,6 +148,31 @@ else
                        }}, desc)
        end
 
+       local function test_certificate_chain()
+               local desc = 'config with certificate chain (with intermediate CA cert)'
+               local host, port = setup_module(desc,
+                       {
+                               tls = true,
+                               cert = 'chain.crt',
+                               key = 'test.key',
+                       })
+               local uri = string.format('https://%s:%d', host, port)
+               local req = request.new_from_uri(uri)
+               req.ctx = openssl_ctx.new()
+
+               if not req.ctx.setCertificateChain then
+                       pass(string.format('SKIP (luaossl <= 20181207) - %s', desc))
+               else
+                       local store = req.ctx:getStore()
+                       store:add('ca.crt')
+                       req.ctx:setVerify(openssl_ctx.VERIFY_PEER)
+
+                       local headers = assert(req:go())
+                       local code = tonumber(headers:get(':status'))
+                       same(code, 200, desc)
+               end
+       end
+
 
        -- plan tests
        local tests = {
@@ -159,7 +184,8 @@ else
                test_nonexistent_key,
                test_missing_key_param,
                test_broken_cert,
-               test_broken_key
+               test_broken_key,
+               test_certificate_chain,
        }
 
        return tests