only dowload CRL once

This commit is contained in:
Artur Neumann committed 2026-10-05 14:20:39 +05:45
1 parent 308f0471b6
commit 57f0bbaf9c
1 file changed
+8 -2
+8 -2
View File
@@ -535,7 +535,7 @@ download_crls_for_chain() {
assert "[ -f $CERT_FILE ]" "Precondition: Certificate file $CERT_FILE must exist." assert "[ -f $CERT_FILE ]" "Precondition: Certificate file $CERT_FILE must exist."
echo -n > "$OUTPUT_FILE" echo -n > "$OUTPUT_FILE"
local CRL_TMP="$TMP_DIR"/crl_tmp.crl
#remove files from possible previous runs #remove files from possible previous runs
rm -f "$TMP_DIR"/*.extracted.pem.cer rm -f "$TMP_DIR"/*.extracted.pem.cer
#extract all contained certificates into separate files #extract all contained certificates into separate files
@@ -553,7 +553,13 @@ download_crls_for_chain() {
local URL=$(openssl x509 -inform PEM -in $EXTRACTED_CERT -text -noout \ local URL=$(openssl x509 -inform PEM -in $EXTRACTED_CERT -text -noout \
| awk '/CRL Distribution Points:/{f=1} f && /URI:/ {print; exit}' \ | awk '/CRL Distribution Points:/{f=1} f && /URI:/ {print; exit}' \
| sed 's/^.*URI://1') | sed 's/^.*URI://1')
if curl -L "$URL" --output "$CRL_TMP" &> "$OUT_STREAM"; then local CRL_TMP="$TMP_DIR"/crl_tmp.$(echo "$URL" | sha256sum -z | awk '{printf "%s",$1}').crl
local CURL_EXIT_CODE=0
if [ ! -f $CRL_TMP ]; then
curl -L "$URL" --output "$CRL_TMP" &> "$OUT_STREAM"
CURL_EXIT_CODE=$?
fi
if [ $CURL_EXIT_CODE -eq 0 ]; then
if openssl crl -in "$CRL_TMP" -inform DER -noout &> "$OUT_STREAM"; then if openssl crl -in "$CRL_TMP" -inform DER -noout &> "$OUT_STREAM"; then
openssl crl -in "$CRL_TMP" -inform DER >> "$OUTPUT_FILE" openssl crl -in "$CRL_TMP" -inform DER >> "$OUTPUT_FILE"
elif openssl crl -in "$CRL_TMP" -inform PEM -noout &> "$OUT_STREAM"; then elif openssl crl -in "$CRL_TMP" -inform PEM -noout &> "$OUT_STREAM"; then