blob: ab8ba18fc39c0b1126303bb77a864777aef879a7 [file] [log] [blame]
William Lallemand2e0dbb72020-04-28 21:52:38 +02001#REGTEST_TYPE=devel
2
3# This reg-test tests the client auth feature of HAProxy for both the backend
4# and frontend section with a CRL list
5#
6# This reg-test uses 2 chained listeners because vtest does not handle the SSL.
7# Test the frontend client auth and the backend side at the same time.
8#
9# The sends 3 requests one with a correct certificate, one with an expired one and one which was revoked.
10# The client then check if we received the right one with the right error.
11#
12# Certificates, CA and CRL are expiring in 2050 so it should be fine for the CI.
13#
14# Detail about configuration is explained there:
15# https://www.haproxy.com/blog/ssl-client-certificate-management-at-application-level/
16
17varnishtest "Test the client auth"
William Lallemand2e0dbb72020-04-28 21:52:38 +020018#REQUIRE_OPTIONS=OPENSSL
19feature ignore_unknown_macro
20
21server s1 -repeat 3 {
22 rxreq
23 txresp
24} -start
25
26haproxy h1 -conf {
27 global
28 tune.ssl.default-dh-param 2048
29
30 defaults
31 mode http
32 option httplog
William Lallemand2e0dbb72020-04-28 21:52:38 +020033 log stderr local0 debug err
34 option logasap
Willy Tarreauf6739232021-11-18 17:46:22 +010035 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
36 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
37 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
William Lallemand2e0dbb72020-04-28 21:52:38 +020038
39 listen clear-lst
40 bind "fd@${clearlst}"
41 balance roundrobin
42 # crt: certificate sent for a client certificate request
43 server s1 "${tmpdir}/ssl.sock" ssl verify none crt ${testdir}/client1.pem
44 server s2 "${tmpdir}/ssl.sock" ssl verify none crt ${testdir}/client2_expired.pem # expired
45 server s3 "${tmpdir}/ssl.sock" ssl verify none crt ${testdir}/client3_revoked.pem # revoked
46
47 listen ssl-lst
48 # crt: certificate of the server
49 # ca-file: CA used for client authentication request
50 # crl-file: revocation list for client auth: the client1 certificate is revoked
William Lallemand960fb742022-11-03 16:31:50 +010051 bind "${tmpdir}/ssl.sock" ssl crt ${testdir}/common.pem ca-file ${testdir}/ca-auth.crt verify optional crt-ignore-err X509_V_ERR_CERT_REVOKED,X509_V_ERR_CERT_HAS_EXPIRED crl-file ${testdir}/crl-auth.pem
William Lallemand2e0dbb72020-04-28 21:52:38 +020052
William Lallemanda415e892023-05-03 15:54:49 +020053 http-response add-header X-SSL %[ssl_c_verify,x509_v_err_str]
William Lallemand2e0dbb72020-04-28 21:52:38 +020054 server s1 ${s1_addr}:${s1_port}
55} -start
56
57client c1 -connect ${h1_clearlst_sock} {
58 txreq
59 rxresp
60 expect resp.status == 200
William Lallemanda415e892023-05-03 15:54:49 +020061 expect resp.http.x-ssl == "X509_V_OK"
William Lallemand2e0dbb72020-04-28 21:52:38 +020062} -run
63
64client c1 -connect ${h1_clearlst_sock} {
65 txreq
66 rxresp
67 expect resp.status == 200
William Lallemanda415e892023-05-03 15:54:49 +020068 expect resp.http.x-ssl == "X509_V_ERR_CERT_HAS_EXPIRED"
William Lallemand2e0dbb72020-04-28 21:52:38 +020069} -run
70
71client c1 -connect ${h1_clearlst_sock} {
72 txreq
73 rxresp
74 expect resp.status == 200
William Lallemanda415e892023-05-03 15:54:49 +020075 expect resp.http.x-ssl == "X509_V_ERR_CERT_REVOKED"
William Lallemand2e0dbb72020-04-28 21:52:38 +020076} -run