Skip to content

Commit 8081023

Browse files
authored
chore(e2e): make sure squid proxy generates a cert containing SANs (#1228)
* add IP SAN to cert generated for squid proxy test * make sure certificate gets generated with IP SANs & explicitly indicate CA
1 parent d7b004d commit 8081023

File tree

1 file changed

+49
-5
lines changed

1 file changed

+49
-5
lines changed

e2e/scripts/install-and-configure-squid.sh

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,76 @@ ssl_bump bump all
1111
http_access allow localnet
1212
"
1313

14+
COUNTRY=US
15+
STATE=State
16+
LOCALITY=City
17+
ORGANIZATION=Replicated
18+
ORGANIZATIONAL_UNIT=IT
19+
COMMON_NAME=10.0.0.254
20+
IP_SAN=10.0.0.254
21+
22+
create_config() {
23+
cat > /etc/squid/ssl_cert/san.cnf <<EOL
24+
[req]
25+
distinguished_name = req_distinguished_name
26+
req_extensions = req_ext
27+
prompt = no
28+
[req_distinguished_name]
29+
C = $COUNTRY
30+
ST = $STATE
31+
L = $LOCALITY
32+
O = $ORGANIZATION
33+
OU = $ORGANIZATIONAL_UNIT
34+
CN = $COMMON_NAME
35+
[req_ext]
36+
subjectAltName = @alt_names
37+
[v3_ca]
38+
subjectAltName = @alt_names
39+
basicConstraints = CA:true
40+
[alt_names]
41+
IP.1 = $IP_SAN
42+
EOL
43+
}
44+
1445
create_ca() {
1546
openssl req -new -newkey rsa:2048 -sha256 \
1647
-days 7 -nodes -x509 -extensions v3_ca \
1748
-keyout /etc/squid/ssl_cert/ca.pem \
1849
-out /etc/squid/ssl_cert/ca.pem \
50+
-config /etc/squid/ssl_cert/san.cnf \
1951
-subj "/C=US/ST=State/L=City/O=Replicated/OU=IT"
2052
openssl x509 -inform PEM -in /etc/squid/ssl_cert/ca.pem \
2153
-out /tmp/ca.crt
2254
}
2355

2456
create_squid_ssl() {
2557
openssl genrsa -out /etc/squid/ssl_cert/proxy.key 2048
26-
openssl req -new -key /etc/squid/ssl_cert/proxy.key \
58+
openssl req \
59+
-new \
60+
-key /etc/squid/ssl_cert/proxy.key \
2761
-out /etc/squid/ssl_cert/proxy.csr \
28-
-subj "/C=US/ST=State/L=City/O=Replicated/OU=IT/CN=10.0.0.254"
29-
openssl x509 -req -in /etc/squid/ssl_cert/proxy.csr \
62+
-config /etc/squid/ssl_cert/san.cnf \
63+
-extensions req_ext \
64+
-subj "/C=US/ST=State/L=City/O=Replicated/OU=IT/CN=10.128.0.4"
65+
openssl x509 \
66+
-req \
67+
-in /etc/squid/ssl_cert/proxy.csr \
3068
-CA /etc/squid/ssl_cert/ca.pem \
31-
-CAkey /etc/squid/ssl_cert/ca.pem -CAcreateserial \
32-
-out /etc/squid/ssl_cert/proxy.crt -days 7 -sha256
69+
-CAkey /etc/squid/ssl_cert/ca.pem \
70+
-CAcreateserial \
71+
-extfile /etc/squid/ssl_cert/san.cnf \
72+
-extensions req_ext \
73+
-out /etc/squid/ssl_cert/proxy.crt \
74+
-days 7 \
75+
-sha256
3376
}
3477

3578

3679
main() {
3780
apt install -y squid-openssl
3881
/usr/lib/squid/security_file_certgen -c -s /opt/ssl.db -M 4MB
3982
mkdir -p /etc/squid/ssl_cert
83+
create_config
4084
create_ca
4185
create_squid_ssl
4286
echo "$squid_config" > /etc/squid/conf.d/ec.conf

0 commit comments

Comments
 (0)