Skip to content

Commit 482fd41

Browse files
committed
Add test for allow_domain accepting ssl_option.
1 parent de8d06b commit 482fd41

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

t/sanity.t

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ AutoSsl::setup();
66

77
repeat_each(1);
88

9-
plan tests => repeat_each() * (blocks() * 6 + 10);
9+
plan tests => repeat_each() * (blocks() * 7 + 1);
1010

1111
check_accum_error_log();
1212
no_long_string();
@@ -929,13 +929,19 @@ lua ssl certificate verify error: (18: self signed certificate)
929929
domain = "non-sni-" .. ssl_options["port"] .. "-$TEST_NGINX_NGROK_HOSTNAME"
930930
elseif ssl_options["port"] == 9444 then
931931
domain = "non-sni-mismatch-" .. ssl_options["port"] .. "-$TEST_NGINX_NGROK_HOSTNAME"
932+
elseif ssl_options["port"] == 9446 then
933+
domain = "non-sni-disallowed-" .. ssl_options["port"] .. "-$TEST_NGINX_NGROK_HOSTNAME"
932934
end
933935
end
934936
935937
return domain, err
936938
end,
937-
allow_domain = function(domain)
938-
return true
939+
allow_domain = function(domain, auto_ssl, ssl_options)
940+
if ssl_options and ssl_options["port"] == 9446 then
941+
return false
942+
else
943+
return true
944+
end
939945
end,
940946
})
941947
auto_ssl:init()
@@ -990,6 +996,21 @@ lua ssl certificate verify error: (18: self signed certificate)
990996
}
991997
}
992998
999+
server {
1000+
listen 9446 ssl;
1001+
ssl_certificate $TEST_NGINX_ROOT_DIR/t/certs/example_fallback.crt;
1002+
ssl_certificate_key $TEST_NGINX_ROOT_DIR/t/certs/example_fallback.key;
1003+
ssl_certificate_by_lua_block {
1004+
auto_ssl:ssl_certificate({ port = 9446 })
1005+
}
1006+
1007+
location /foo {
1008+
server_tokens off;
1009+
more_clear_headers Date;
1010+
echo "foo";
1011+
}
1012+
}
1013+
9931014
server {
9941015
listen 9080;
9951016
location /.well-known/acme-challenge/ {
@@ -1014,7 +1035,7 @@ lua ssl certificate verify error: (18: self signed certificate)
10141035
lua_ssl_verify_depth 5;
10151036
location /t {
10161037
content_by_lua_block {
1017-
local ports = { 9443, 9444, 9445 }
1038+
local ports = { 9443, 9444, 9445, 9446 }
10181039
for _, port in ipairs(ports) do
10191040
local sock = ngx.socket.tcp()
10201041
sock:settimeout(30000)
@@ -1063,13 +1084,16 @@ GET /t
10631084
failed to do SSL handshake: 9443: 18: self signed certificate
10641085
failed to do SSL handshake: 9444: 18: self signed certificate
10651086
failed to do SSL handshake: 9445: 18: self signed certificate
1087+
failed to do SSL handshake: 9446: 18: self signed certificate
10661088
--- error_log
10671089
auto-ssl: issuing new certificate for non-sni-9443-
10681090
lua ssl certificate verify error: (18: self signed certificate)
10691091
auto-ssl: issuing new certificate for non-sni-mismatch-9444-
10701092
lua ssl certificate verify error: (18: self signed certificate)
10711093
auto-ssl: could not determine domain for request (SNI not supported?) - using fallback -
10721094
lua ssl certificate verify error: (18: self signed certificate)
1095+
auto-ssl: domain not allowed - using fallback - non-sni-disallowed-9446-
1096+
lua ssl certificate verify error: (18: self signed certificate)
10731097
--- no_error_log
10741098
[alert]
10751099
[emerg]

0 commit comments

Comments
 (0)