Skip to content

Commit 49479ba

Browse files
committed
tests: fix ssl generation
the "integration-dind-ssl" tests were failing due to an issue with the test-certs created; ==================================== ERRORS ==================================== _________ ERROR at setup of BuildTest.test_build_container_with_target _________ /usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py:464: in _make_request self._validate_conn(conn) /usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py:1093: in _validate_conn conn.connect() /usr/local/lib/python3.12/site-packages/urllib3/connection.py:790: in connect sock_and_verified = _ssl_wrap_socket_and_match_hostname( /usr/local/lib/python3.12/site-packages/urllib3/connection.py:969: in _ssl_wrap_socket_and_match_hostname ssl_sock = ssl_wrap_socket( /usr/local/lib/python3.12/site-packages/urllib3/util/ssl_.py:480: in ssl_wrap_socket ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname) /usr/local/lib/python3.12/site-packages/urllib3/util/ssl_.py:524: in _ssl_wrap_socket_impl return ssl_context.wrap_socket(sock, server_hostname=server_hostname) /usr/local/lib/python3.12/ssl.py:455: in wrap_socket return self.sslsocket_class._create( /usr/local/lib/python3.12/ssl.py:1041: in _create self.do_handshake() /usr/local/lib/python3.12/ssl.py:1319: in do_handshake self._sslobj.do_handshake() E ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: invalid CA certificate (_ssl.c:1010) During handling of the above exception, another exception occurred: /usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py:787: in urlopen response = self._make_request( /usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py:488: in _make_request raise new_e E urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: invalid CA certificate (_ssl.c:1010) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 6e6a273 commit 49479ba

File tree

1 file changed

+36
-7
lines changed

1 file changed

+36
-7
lines changed

tests/Dockerfile-dind-certs

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,46 @@ RUN mkdir /tmp/certs
77
VOLUME /certs
88

99
WORKDIR /tmp/certs
10+
11+
# ---- CA (with proper v3_ca) ----
1012
RUN openssl genrsa -aes256 -passout pass:foobar -out ca-key.pem 4096
11-
RUN echo "[req]\nprompt=no\ndistinguished_name = req_distinguished_name\n[req_distinguished_name]\ncountryName=AU" > /tmp/config
12-
RUN openssl req -new -x509 -passin pass:foobar -config /tmp/config -days 365 -key ca-key.pem -sha256 -out ca.pem
13-
RUN openssl genrsa -out server-key.pem -passout pass:foobar 4096
13+
COPY <<'EOF' /tmp/ca.cnf
14+
[req]
15+
prompt = no
16+
distinguished_name = req_distinguished_name
17+
x509_extensions = v3_ca
18+
19+
[req_distinguished_name]
20+
countryName = AU
21+
22+
[v3_ca]
23+
basicConstraints = critical, CA:TRUE
24+
keyUsage = critical, keyCertSign, cRLSign
25+
subjectKeyIdentifier = hash
26+
authorityKeyIdentifier = keyid:always,issuer
27+
EOF
28+
RUN openssl req -new -x509 -passin pass:foobar -config /tmp/ca.cnf -days 365 -key ca-key.pem -sha256 -out ca.pem
29+
30+
# ---- Server cert (SAN + KU/EKU) ----
31+
RUN openssl genrsa -out server-key.pem 4096
1432
RUN openssl req -subj "/CN=docker" -sha256 -new -key server-key.pem -out server.csr
15-
RUN echo subjectAltName = DNS:docker,DNS:localhost > extfile.cnf
16-
RUN openssl x509 -req -days 365 -passin pass:foobar -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out server-cert.pem -extfile extfile.cnf
33+
COPY <<'EOF' /tmp/server-ext.cnf
34+
basicConstraints = CA:FALSE
35+
keyUsage = critical, digitalSignature, keyEncipherment
36+
extendedKeyUsage = serverAuth
37+
subjectAltName = DNS:docker, DNS:localhost
38+
EOF
39+
RUN openssl x509 -req -days 365 -passin pass:foobar -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out server-cert.pem -extfile /tmp/server-ext.cnf
40+
41+
# ---- Client cert (KU/EKU) ----
1742
RUN openssl genrsa -out key.pem 4096
1843
RUN openssl req -passin pass:foobar -subj '/CN=client' -new -key key.pem -out client.csr
19-
RUN echo extendedKeyUsage = clientAuth > extfile.cnf
20-
RUN openssl x509 -req -passin pass:foobar -days 365 -sha256 -in client.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out cert.pem -extfile extfile.cnf
44+
COPY <<'EOF' /tmp/client-ext.cnf
45+
basicConstraints = CA:FALSE
46+
keyUsage = critical, digitalSignature
47+
extendedKeyUsage = clientAuth
48+
EOF
49+
RUN openssl x509 -req -passin pass:foobar -days 365 -sha256 -in client.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out cert.pem -extfile /tmp/client-ext.cnf
2150
RUN chmod -v 0400 ca-key.pem key.pem server-key.pem
2251
RUN chmod -v 0444 ca.pem server-cert.pem cert.pem
2352

0 commit comments

Comments
 (0)