Skip to content

Commit d80c42b

Browse files
committed
tests: add CRL mTLS test.
This commit adds a simple test CRL (`testdata/test.crl.pem`) that lists the `testdata/localhost/cert.pem` certificate as revoked, but _not_ the `testdata/example.com/cert.pem` certificate. The `client-server.py` integration test driver is then updated with a suite that will start the server binary in a mode that requires mTLS, and that loads the test crl. Two connection attempts are made with the client binary: one using the `example.com` client cert that isn't expected to error, and one using the `localhost` client cert that _is_ expected to error (since it's revoked).
1 parent 18d2279 commit d80c42b

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

testdata/test.crl.pem

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-----BEGIN X509 CRL-----
2+
MIIBxjCBrwIBATANBgkqhkiG9w0BAQsFADAgMR4wHAYDVQQDExVtaW5pY2Egcm9v
3+
dCBjYSAxMGE3YTAXDTIzMDcwMzE3MTgxMloXDTIzMDcxMDE3MTgxMlowKTAnAghT
4+
E+2CSHaYmBcNMjMwNzAzMTcxNzU5WjAMMAoGA1UdFQQDCgEBoDAwLjAfBgNVHSME
5+
GDAWgBQ19H4hMuTID22xvBfISviOa+S+EDALBgNVHRQEBAICEAEwDQYJKoZIhvcN
6+
AQELBQADggEBAF5fOpNZGLsHGAUasx5Il79My6EU66igE0YZWVzgX8EaCt1RMCFx
7+
osumXkaPiohICSsczFlnJolpwacsHx/K/IMYvthna8lbAxhuWharRqoHUK+BdTDD
8+
wtThMBC2dCNoLro/6cIpMov9OXjh8291ogIy0qIiSm20JiaWTB+0V7A6gA7riTXC
9+
yzJTyGECLS9XP6rt+SYmcDn0D1jxfsIli0kYBJdKb3O0xF05oBaWadSLuXbcA41+
10+
Kcw07HACaUrR6BCrR3CjnnlTl6Pr25cQi3zPya7lNDQWqhLNx0sU2jviVZQe1nIA
11+
Ie8Ha2syCv0aa33s0dUY6hOKDbLTGpI8f/E=
12+
-----END X509 CRL-----

tests/client-server.py

+42-1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,38 @@ def run_mtls_client_tests(client, valgrind):
131131
)
132132

133133

134+
def run_mtls_client_crl_tests(client, valgrind):
135+
run_with_maybe_valgrind(
136+
[
137+
client,
138+
HOST,
139+
str(PORT),
140+
"/"
141+
],
142+
{
143+
"CA_FILE": "testdata/minica.pem",
144+
"AUTH_CERT": "testdata/example.com/cert.pem",
145+
"AUTH_KEY": "testdata/example.com/key.pem",
146+
},
147+
valgrind
148+
)
149+
run_with_maybe_valgrind(
150+
[
151+
client,
152+
HOST,
153+
str(PORT),
154+
"/"
155+
],
156+
{
157+
"CA_FILE": "testdata/minica.pem",
158+
"AUTH_CERT": "testdata/localhost/cert.pem",
159+
"AUTH_KEY": "testdata/localhost/key.pem",
160+
},
161+
valgrind,
162+
expect_error=True # Client connecting w/ revoked cert should err.
163+
)
164+
165+
134166
def run_server(server, valgrind, env):
135167
args = [
136168
server,
@@ -181,10 +213,19 @@ def main():
181213
server_popen.wait()
182214

183215
# Client/server tests w/ mandatory client authentication.
184-
run_server(server, valgrind, {
216+
server_popen = run_server(server, valgrind, {
185217
"AUTH_CERT": "testdata/minica.pem",
186218
})
187219
run_mtls_client_tests(client, valgrind)
220+
server_popen.kill()
221+
server_popen.wait()
222+
223+
# Client/server tests w/ mandatory client authentication & CRL.
224+
run_server(server, valgrind, {
225+
"AUTH_CERT": "testdata/minica.pem",
226+
"AUTH_CRL": "testdata/test.crl.pem",
227+
})
228+
run_mtls_client_crl_tests(client, valgrind)
188229

189230

190231
if __name__ == "__main__":

0 commit comments

Comments
 (0)