Skip to content

Commit ec7f428

Browse files
authored
Merge pull request #501 from dduportal/helpdesk-4951
chore(updatecli) track CRL expiration
2 parents 3993769 + 0fdeb15 commit ec7f428

File tree

2 files changed

+76
-4
lines changed

2 files changed

+76
-4
lines changed

updatecli/scripts/cert-expiry-extract.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
#!/bin/bash
22
# Extract expiration date from an OpenVPN certificate
3-
set -eu -o pipefail
3+
set -eux -o pipefail
44

55
cert_file="${1}"
6+
cert_type="${2:-x509}"
67

78
if [ ! -f "${cert_file}" ]; then
89
echo "ERROR: Certificate file ${cert_file} not found"
910
exit 1
1011
fi
1112

12-
# Extract the notAfter date from the certificate
13-
# Output format: notAfter=Jan 15 12:34:56 2026 GMT
14-
expiry_raw=$(openssl x509 -enddate -noout -in "${cert_file}" 2>/dev/null | cut -d= -f2)
13+
case "${cert_type}" in
14+
"x509")
15+
# Extract the notAfter date from the certificate
16+
# Output format: notAfter=Jan 15 12:34:56 2026 GMT
17+
expiry_raw="$(openssl x509 -enddate -noout -in "${cert_file}" 2>/dev/null | cut -d= -f2)"
18+
;;
19+
"crl")
20+
# Extract the nextUpdate date from the certificate
21+
# Output format: nextUpdate=Jun 1 10:20:48 2026 GMT
22+
expiry_raw="$(openssl crl --nextupdate -noout -in "${cert_file}" 2>/dev/null | cut -d= -f2)"
23+
;;
24+
*)
25+
echo "ERROR: unsupported certificate type ${cert_type}".
26+
exit 1
27+
;;
28+
esac
1529

1630
if [ -z "${expiry_raw}" ]; then
1731
echo "ERROR: Could not extract expiration date from ${cert_file}"
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
name: Check VPN CRL expiration
3+
4+
scms:
5+
default:
6+
kind: github
7+
spec:
8+
user: "{{ $.github.user }}"
9+
email: "{{ $.github.email }}"
10+
owner: "{{ $.github.owner }}"
11+
repository: "{{ $.github.repository }}"
12+
token: "{{ requiredEnv $.github.token }}"
13+
branch: "{{ $.github.branch }}"
14+
15+
sources:
16+
crlExpiryDate:
17+
name: Extract CRL expiration date
18+
kind: shell
19+
spec:
20+
command: bash ./updatecli/scripts/cert-expiry-extract.sh ./cert/pki/crl.pem crl
21+
22+
conditions:
23+
checkIfExpiringSoon:
24+
name: Check if certificate expires within 30 days
25+
kind: shell
26+
sourceid: crlExpiryDate
27+
spec:
28+
command: bash ./updatecli/scripts/cert-expiry-check.sh
29+
30+
targets:
31+
markCertExpiring:
32+
name: Mark CRL certificate as expiring
33+
kind: file
34+
disablesourceinput: true
35+
spec:
36+
file: ./cert/pki/crl.pem
37+
content: |
38+
Certificate Revocation List expires on {{ source "crlExpiryDate" }}.
39+
Please renew the VPN CRL following https://github.com/jenkins-infra/docker-openvpn?tab=readme-ov-file#howto-renew-certificate-revocation-list.
40+
scmid: default
41+
42+
actions:
43+
default:
44+
kind: github/pullrequest
45+
scmid: default
46+
spec:
47+
draft: true
48+
title: "[DO NOT MERGE] VPN CRL Expiring Soon"
49+
description: |
50+
@jenkins-infra/jenkins-infra-sre-team The VPN CRL will expire on **{{ source "crlExpiryDate" }}**.
51+
52+
## Action Required
53+
54+
Please create an issue on the helpdesk and follow instructions from https://github.com/jenkins-infra/docker-openvpn?tab=readme-ov-file#howto-renew-certificate-revocation-list.
55+
56+
---
57+
**Note:** This is an automated notification PR.
58+
It is not meant to be merged and can be closed once acknowledged.

0 commit comments

Comments
 (0)