blob: b8107d4434b1252056d78486d3ad669ae52ffb60 [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
53 acl cert_expired ssl_c_verify 10
54 acl cert_revoked ssl_c_verify 23
55 acl cert_ok ssl_c_verify 0
56
57 http-response add-header X-SSL Ok if cert_ok
58 http-response add-header X-SSL Expired if cert_expired
59 http-response add-header X-SSL Revoked if cert_revoked
60
61 server s1 ${s1_addr}:${s1_port}
62} -start
63
64client c1 -connect ${h1_clearlst_sock} {
65 txreq
66 rxresp
67 expect resp.status == 200
68 expect resp.http.x-ssl == "Ok"
69} -run
70
71client c1 -connect ${h1_clearlst_sock} {
72 txreq
73 rxresp
74 expect resp.status == 200
75 expect resp.http.x-ssl == "Expired"
76} -run
77
78client c1 -connect ${h1_clearlst_sock} {
79 txreq
80 rxresp
81 expect resp.status == 200
82 expect resp.http.x-ssl == "Revoked"
83} -run