1414 params :
1515 - description : A docker image of operator-pipeline-images for the steps to run in
1616 name : pipeline_image
17- default : " quay.io/konflux-ci/release-service-utils:82012e03002128f2a226acb23dc5c6fc1c37f5b6 "
17+ default : " quay.io/konflux-ci/release-service-utils:13e379cb498293f8f7b8b9c84c57d9e8ab141be2 "
1818 type : string
1919 - description : Name of the user that requested the signing, for auditing purposes
2020 name : requester
9898 computeResources :
9999 limits :
100100 memory : 128Mi
101+ cpu : 100m
101102 requests :
102103 memory : 128Mi
103104 cpu : 100m
@@ -108,13 +109,9 @@ spec:
108109 readOnly : true
109110 script : |
110111 #!/usr/bin/env bash
111- set -x
112112 umb_cert="$(cat "/mnt/umb_ssl_cert_secret/$(params.umb_ssl_cert_file_name)")"
113113 issuer="$(openssl x509 -noout -subject <<< "$umb_cert" \
114114 | awk '{print substr($0, index($0, "UID=")+4)}')"
115-
116- openssl rsa -in "/mnt/umb_ssl_cert_secret/$(params.umb_ssl_key_file_name)" -check
117-
118115 echo -n "${issuer}" | tee "$(results.certificate-issuer.path)"
119116
120117 - name : build-pubtools-sign-config
@@ -124,6 +121,7 @@ spec:
124121 computeResources :
125122 limits :
126123 memory : 128Mi
124+ cpu : 100m
127125 requests :
128126 memory : 128Mi
129127 cpu : 100m
@@ -205,6 +203,7 @@ spec:
205203 computeResources :
206204 limits :
207205 memory : 128Mi
206+ cpu : 100m
208207 requests :
209208 memory : 128Mi
210209 cpu : 100m
@@ -236,6 +235,7 @@ spec:
236235 computeResources :
237236 limits :
238237 memory : 128Mi
238+ cpu : 100m
239239 requests :
240240 memory : 128Mi
241241 cpu : 100m
@@ -260,22 +260,74 @@ spec:
260260 echo $(context.taskRun.uid)
261261 fi
262262 }
263+ PY_SCRIPT=$(cat <<'END_HEREDOC'
264+ import os
265+ import proton
266+ import sys
267+ from cryptography import x509
268+ from cryptography.hazmat.primitives import serialization
269+ from cryptography.hazmat.primitives.asymmetric import rsa
270+
271+ def validate_ssl_pair(cert_path, key_path):
272+ try:
273+ # 1. Load and Validate Certificate
274+ with open(cert_path, "rb") as f:
275+ cert_data = f.read()
276+ cert = x509.load_pem_x509_certificate(cert_data)
277+
278+ # 2. Load and Validate Private Key
279+ with open(key_path, "rb") as f:
280+ key_data = f.read()
281+ # If your key has a password, provide it in 'password='
282+ private_key = serialization.load_pem_private_key(key_data, password=None)
283+
284+ # 3. Check if they match
285+ # We compare the public key derived from the cert vs the one from the private key
286+ cert_pub_key = cert.public_key().public_bytes(
287+ encoding=serialization.Encoding.PEM,
288+ format=serialization.PublicFormat.SubjectPublicKeyInfo
289+ )
290+ key_pub_key = private_key.public_key().public_bytes(
291+ encoding=serialization.Encoding.PEM,
292+ format=serialization.PublicFormat.SubjectPublicKeyInfo
293+ )
294+
295+ if cert_pub_key == key_pub_key:
296+ return True, "Valid pair: Private key matches certificate."
297+ else:
298+ return False, "Mismatch: Private key does not belong to this certificate."
299+
300+ except Exception as e:
301+ return False, f"Validation error: {str(e)}"
302+
303+ print(f'Cert exists: {os.path.exists(sys.argv[1])}');
304+ print(f'Cert is readable: {os.access(sys.argv[1], os.R_OK)}');
305+ print(f'Proton SSL ready: {proton.SSL.present()}');
306+
307+ is_valid, message = validate_ssl_pair(sys.argv[1], sys.argv[1])
308+ print(message)
309+
310+ ssl_domain=proton.SSLDomain(proton.SSLDomain.MODE_CLIENT);
311+ ssl_domain.set_credentials(sys.argv[1], sys.argv[1], None)
312+ END_HEREDOC
313+ )
314+ echo "$PY_SCRIPT" > /tmp/validate_ssl.py
263315
264316 umb_cert="$(cat "/mnt/umb_ssl_cert_secret/$(params.umb_ssl_cert_file_name)")"
265317 umb_key="$(cat "/mnt/umb_ssl_cert_secret/$(params.umb_ssl_key_file_name)")"
266318
267319 echo "${umb_cert:?}" > /tmp/umb.pem.$(get-task-id)
268320 echo "${umb_key:?}" >> /tmp/umb.pem.$(get-task-id)
269321 set -xe
270- python3 -c "import proton;
271- ssl_domain=proton.SSLDomain(proton.SSLDomain.MODE_CLIENT);
272- cert='/tmp/umb.pem.$(get-task-id)';
273- ssl_domain.set_credentials(cert, cert, None)"
322+ cert="/tmp/umb.pem.$(get-task-id)"
323+ python3 /tmp/validate_ssl.py "${cert}"
324+
274325 - name : request-signature
275326 image : " $(params.pipeline_image)"
276327 computeResources :
277328 limits :
278329 memory : 128Mi
330+ cpu : 100m
279331 requests :
280332 memory : 128Mi
281333 cpu : 100m
@@ -344,6 +396,7 @@ spec:
344396 computeResources :
345397 limits :
346398 memory : 128Mi
399+ cpu : 100m
347400 requests :
348401 memory : 128Mi
349402 cpu : 100m
0 commit comments