Skip to content

Commit d964853

Browse files
committed
Tests: dynamic certificates to upstream in optimized SSL contexts.
1 parent 981b880 commit d964853

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

proxy_ssl_certificate_vars.t

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ http {
4343
4444
proxy_ssl_session_reuse off;
4545
46+
proxy_ssl_certificate $arg_cert.example.com.crt;
47+
proxy_ssl_certificate_key $arg_cert.example.com.key;
48+
proxy_ssl_password_file password;
49+
4650
location / {
4751
proxy_pass https://127.0.0.1:8081/;
48-
proxy_ssl_certificate $arg_cert.example.com.crt;
49-
proxy_ssl_certificate_key $arg_cert.example.com.key;
5052
}
5153
5254
location /encrypted {
@@ -56,6 +58,10 @@ http {
5658
proxy_ssl_password_file password;
5759
}
5860
61+
location /optimized {
62+
proxy_pass https://127.0.0.1:8082/;
63+
}
64+
5965
location /none {
6066
proxy_pass https://127.0.0.1:8082/;
6167
proxy_ssl_certificate $arg_cert;
@@ -132,7 +138,7 @@ sleep 1 if $^O eq 'MSWin32';
132138
$t->write_file('password', '3.example.com');
133139
$t->write_file('index.html', '');
134140

135-
$t->run()->plan(4);
141+
$t->run()->plan(5);
136142

137143
###############################################################################
138144

@@ -142,6 +148,16 @@ like(http_get('/?cert=2'),
142148
qr/X-Verify: FAILED/ms, 'variable - fail certificate');
143149
like(http_get('/encrypted?cert=3'),
144150
qr/X-Verify: SUCCESS/ms, 'variable - with encrypted key');
151+
152+
TODO: {
153+
todo_skip 'leaves coredump', 1 unless $t->has_version('1.27.5')
154+
or $ENV{TEST_NGINX_UNSAFE};
155+
156+
like(http_get('/optimized?cert=3'),
157+
qr/X-Verify: SUCCESS/ms, 'variable - with encrypted key optimized');
158+
159+
}
160+
145161
like(http_get('/none'),
146162
qr/X-Verify: NONE/ms, 'variable - no certificate');
147163

stream_proxy_ssl_certificate_vars.t

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,21 @@ stream {
4141
%%PORT_8082%% 1;
4242
%%PORT_8083%% 2;
4343
%%PORT_8084%% 3;
44+
%%PORT_8086%% 3;
4445
%%PORT_8085%% "";
4546
}
4647
4748
proxy_ssl on;
4849
proxy_ssl_session_reuse off;
4950
51+
proxy_ssl_certificate $cert.example.com.crt;
52+
proxy_ssl_certificate_key $cert.example.com.key;
53+
proxy_ssl_password_file password;
54+
5055
server {
5156
listen 127.0.0.1:8082;
5257
listen 127.0.0.1:8083;
5358
proxy_pass 127.0.0.1:8080;
54-
55-
proxy_ssl_certificate $cert.example.com.crt;
56-
proxy_ssl_certificate_key $cert.example.com.key;
5759
}
5860
5961
server {
@@ -65,6 +67,11 @@ stream {
6567
proxy_ssl_password_file password;
6668
}
6769
70+
server {
71+
listen 127.0.0.1:8086;
72+
proxy_pass 127.0.0.1:8081;
73+
}
74+
6875
server {
6976
listen 127.0.0.1:8085;
7077
proxy_pass 127.0.0.1:8081;
@@ -146,7 +153,7 @@ sleep 1 if $^O eq 'MSWin32';
146153
$t->write_file('password', '3.example.com');
147154
$t->write_file('index.html', '');
148155

149-
$t->run()->plan(4);
156+
$t->run()->plan(5);
150157

151158
###############################################################################
152159

@@ -156,6 +163,16 @@ like(http_get('/', socket => IO::Socket::INET->new('127.0.0.1:' . port(8083))),
156163
qr/X-Verify: FAILED/ms, 'variable - fail certificate');
157164
like(http_get('/', socket => IO::Socket::INET->new('127.0.0.1:' . port(8084))),
158165
qr/X-Verify: SUCCESS/ms, 'variable - with encrypted key');
166+
167+
TODO: {
168+
todo_skip 'leaves coredump', 1 unless $t->has_version('1.27.5')
169+
or $ENV{TEST_NGINX_UNSAFE};
170+
171+
like(http_get('/', socket => IO::Socket::INET->new('127.0.0.1:' . port(8086))),
172+
qr/X-Verify: SUCCESS/ms, 'variable - with encrypted key optimized');
173+
174+
}
175+
159176
like(http_get('/', socket => IO::Socket::INET->new('127.0.0.1:' . port(8085))),
160177
qr/X-Verify: NONE/ms, 'variable - no certificate');
161178

0 commit comments

Comments
 (0)