Merge pull request #4274 from ElvinEfendi/support-trailing-dot
Support trailing dot
This commit is contained in:
commit
17d99c4aba
3 changed files with 22 additions and 1 deletions
|
@ -28,7 +28,9 @@ local function set_pem_cert_key(pem_cert_key)
|
|||
end
|
||||
end
|
||||
|
||||
local function get_pem_cert_key(hostname)
|
||||
local function get_pem_cert_key(raw_hostname)
|
||||
local hostname = re_sub(raw_hostname, "\\.$", "", "jo")
|
||||
|
||||
local pem_cert_key = configuration.get_pem_cert_key(hostname)
|
||||
if pem_cert_key then
|
||||
return pem_cert_key
|
||||
|
|
|
@ -66,6 +66,20 @@ describe("Certificate", function()
|
|||
assert_certificate_is_set(EXAMPLE_CERT)
|
||||
end)
|
||||
|
||||
it("sets certificate and key for domain with trailing dot", function()
|
||||
ssl.server_name = function() return "hostname.", nil end
|
||||
ngx.shared.certificate_data:set("hostname", EXAMPLE_CERT)
|
||||
|
||||
assert_certificate_is_set(EXAMPLE_CERT)
|
||||
end)
|
||||
|
||||
it("fallbacks to default certificate and key for domain with many trailing dots", function()
|
||||
ssl.server_name = function() return "hostname..", nil end
|
||||
ngx.shared.certificate_data:set("hostname", EXAMPLE_CERT)
|
||||
|
||||
assert_certificate_is_set(DEFAULT_CERT)
|
||||
end)
|
||||
|
||||
it("sets certificate and key for nested wildcard cert", function()
|
||||
ssl.server_name = function() return "sub.nested.hostname", nil end
|
||||
ngx.shared.certificate_data:set("*.nested.hostname", EXAMPLE_CERT)
|
||||
|
|
|
@ -130,6 +130,11 @@ var _ = framework.IngressNginxDescribe("Dynamic Certificate", func() {
|
|||
ensureHTTPSRequest(f.GetURL(framework.HTTPS), host, host)
|
||||
})
|
||||
|
||||
/*
|
||||
TODO(elvinefendi): this test currently does not work as expected
|
||||
because Go transport code strips (https://github.com/golang/go/blob/431b5c69ca214ce4291f008c1ce2a50b22bc2d2d/src/crypto/tls/handshake_messages.go#L424)
|
||||
trailing dot from SNI as suggest by the standard (https://tools.ietf.org/html/rfc6066#section-3).
|
||||
*/
|
||||
It("supports requests with domain with trailing dot", func() {
|
||||
ensureHTTPSRequest(f.GetURL(framework.HTTPS), host+".", host)
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue