blob: f82be7b1652d91e38925d608a6109526bade1e22 [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"
18#REQUIRE_VERSION=1.6
19#REQUIRE_OPTIONS=OPENSSL
20feature ignore_unknown_macro
21
22server s1 -repeat 3 {
23 rxreq
24 txresp
25} -start
26
27haproxy h1 -conf {
28 global
29 tune.ssl.default-dh-param 2048
30
31 defaults
32 mode http
33 option httplog
William Lallemand2e0dbb72020-04-28 21:52:38 +020034 log stderr local0 debug err
35 option logasap
36 timeout connect 1s
37 timeout client 1s
38 timeout server 1s
39
40 listen clear-lst
41 bind "fd@${clearlst}"
42 balance roundrobin
43 # crt: certificate sent for a client certificate request
44 server s1 "${tmpdir}/ssl.sock" ssl verify none crt ${testdir}/client1.pem
45 server s2 "${tmpdir}/ssl.sock" ssl verify none crt ${testdir}/client2_expired.pem # expired
46 server s3 "${tmpdir}/ssl.sock" ssl verify none crt ${testdir}/client3_revoked.pem # revoked
47
48 listen ssl-lst
49 # crt: certificate of the server
50 # ca-file: CA used for client authentication request
51 # crl-file: revocation list for client auth: the client1 certificate is revoked
52 bind "${tmpdir}/ssl.sock" ssl crt ${testdir}/common.pem ca-file ${testdir}/ca-auth.crt verify optional crt-ignore-err all crl-file ${testdir}/crl-auth.pem
53
54 acl cert_expired ssl_c_verify 10
55 acl cert_revoked ssl_c_verify 23
56 acl cert_ok ssl_c_verify 0
57
58 http-response add-header X-SSL Ok if cert_ok
59 http-response add-header X-SSL Expired if cert_expired
60 http-response add-header X-SSL Revoked if cert_revoked
61
62 server s1 ${s1_addr}:${s1_port}
63} -start
64
65client c1 -connect ${h1_clearlst_sock} {
66 txreq
67 rxresp
68 expect resp.status == 200
69 expect resp.http.x-ssl == "Ok"
70} -run
71
72client c1 -connect ${h1_clearlst_sock} {
73 txreq
74 rxresp
75 expect resp.status == 200
76 expect resp.http.x-ssl == "Expired"
77} -run
78
79client c1 -connect ${h1_clearlst_sock} {
80 txreq
81 rxresp
82 expect resp.status == 200
83 expect resp.http.x-ssl == "Revoked"
84} -run