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
@@ -124,6 +125,7 @@ spec:
124125 computeResources :
125126 limits :
126127 memory : 128Mi
128+ cpu : 100m
127129 requests :
128130 memory : 128Mi
129131 cpu : 100m
@@ -236,6 +238,7 @@ spec:
236238 computeResources :
237239 limits :
238240 memory : 128Mi
241+ cpu : 100m
239242 requests :
240243 memory : 128Mi
241244 cpu : 100m
@@ -260,14 +263,67 @@ spec:
260263 echo $(context.taskRun.uid)
261264 fi
262265 }
266+ PY_SCRIPT=$(cat <<'END_HEREDOC'
267+ import os
268+ import sys
269+ from cryptography import x509
270+ from cryptography.hazmat.primitives import serialization
271+ from cryptography.hazmat.primitives.asymmetric import rsa
272+
273+ def validate_ssl_pair(cert_path, key_path):
274+ try:
275+ # 1. Load and Validate Certificate
276+ with open(cert_path, "rb") as f:
277+ cert_data = f.read()
278+ cert = x509.load_pem_x509_certificate(cert_data)
279+
280+ # 2. Load and Validate Private Key
281+ with open(key_path, "rb") as f:
282+ key_data = f.read()
283+ # If your key has a password, provide it in 'password='
284+ private_key = serialization.load_pem_private_key(key_data, password=None)
285+
286+ # 3. Check if they match
287+ # We compare the public key derived from the cert vs the one from the private key
288+ cert_pub_key = cert.public_key().public_bytes(
289+ encoding=serialization.Encoding.PEM,
290+ format=serialization.PublicFormat.SubjectPublicKeyInfo
291+ )
292+ key_pub_key = private_key.public_key().public_bytes(
293+ encoding=serialization.Encoding.PEM,
294+ format=serialization.PublicFormat.SubjectPublicKeyInfo
295+ )
296+
297+ if cert_pub_key == key_pub_key:
298+ return True, "Valid pair: Private key matches certificate."
299+ else:
300+ return False, "Mismatch: Private key does not belong to this certificate."
301+
302+ except Exception as e:
303+ return False, f"Validation error: {str(e)}"
304+
305+ print(f'Cert exists: {os.path.exists(sys.argv[1])}');
306+ print(f'Cert is readable: {os.access(sys.argv[1], os.R_OK)}');
307+ is_valid, message = validate_ssl_pair(sys.argv[1], sys.argv[1])
308+ print(message)
309+ END_HEREDOC
310+ )
311+ echo "$PY_SCRIPT" > /tmp/validate_ssl.py
263312
264313 umb_cert="$(cat "/mnt/umb_ssl_cert_secret/$(params.umb_ssl_cert_file_name)")"
265314 umb_key="$(cat "/mnt/umb_ssl_cert_secret/$(params.umb_ssl_key_file_name)")"
266315
267316 echo "${umb_cert:?}" > /tmp/umb.pem.$(get-task-id)
268317 echo "${umb_key:?}" >> /tmp/umb.pem.$(get-task-id)
269318 set -xe
270- python3 -c "import proton;
319+ cert="/tmp/umb.pem.$(get-task-id)"
320+
321+ python3 /tmp/validate_ssl.py "${cert}"
322+ python3 -c "import proton; import os;
323+ cert='/tmp/umb.pem.$(get-task-id)';
324+ print(f'Cert exists: {os.path.exists(cert)}');
325+ print(f'Cert is readable: {os.access(cert, os.R_OK)}');
326+ print(f'Proton SSL ready: {proton.SSL.present()}');
271327 ssl_domain=proton.SSLDomain(proton.SSLDomain.MODE_CLIENT);
272328 cert='/tmp/umb.pem.$(get-task-id)';
273329 ssl_domain.set_credentials(cert, cert, None)"
@@ -276,6 +332,7 @@ spec:
276332 computeResources :
277333 limits :
278334 memory : 128Mi
335+ cpu : 100m
279336 requests :
280337 memory : 128Mi
281338 cpu : 100m
@@ -344,6 +401,7 @@ spec:
344401 computeResources :
345402 limits :
346403 memory : 128Mi
404+ cpu : 100m
347405 requests :
348406 memory : 128Mi
349407 cpu : 100m
0 commit comments