-
Notifications
You must be signed in to change notification settings - Fork 73
🌱 Preserve Mozilla v5.8 old TLS profile and harden update script #2632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
openshift-merge-bot
merged 1 commit into
operator-framework:main
from
tmshort:tls-profiles-old-profile-preservation
Apr 8, 2026
+157
−82
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,52 +8,112 @@ if [ -z "${JQ}" ]; then | |
| fi | ||
|
|
||
| OUTPUT=internal/shared/util/tlsprofiles/mozilla_data.go | ||
| INPUT=https://ssl-config.mozilla.org/guidelines/5.8.json | ||
| INPUT=https://ssl-config.mozilla.org/guidelines/latest.json | ||
|
|
||
| TMPFILE="$(mktemp)" | ||
| trap 'rm -rf "$TMPFILE"' EXIT | ||
|
|
||
| curl -L -s ${INPUT} > ${TMPFILE} | ||
| if ! curl -L -s -f "${INPUT}" > "${TMPFILE}"; then | ||
| echo "ERROR: Failed to download ${INPUT} (HTTP error or connection failure)" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! ${JQ} empty "${TMPFILE}" 2>/dev/null; then | ||
| echo "ERROR: Downloaded data from ${INPUT} is not valid JSON" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| version=$(${JQ} -r '.version' ${TMPFILE}) | ||
| # Extract stored version from current output file (may be empty on first run) | ||
| STORED_VERSION=$(grep '^// DATA VERSION:' "${OUTPUT}" 2>/dev/null | awk '{print $4}' || true) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: the "|| true" may be dropped here as the grep is in a pipe with awk and the overall result would never fail (as the awk command would not fail). Still looks more robust this way. |
||
|
|
||
| cat > ${OUTPUT} <<EOF | ||
| # Extract version from downloaded JSON and fail early if missing | ||
| NEW_VERSION=$(${JQ} -r '.version' "${TMPFILE}") | ||
| if [ -z "${NEW_VERSION}" ] || [ "${NEW_VERSION}" = "null" ]; then | ||
| echo "ERROR: Could not read .version from ${INPUT}" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "${NEW_VERSION}" = "${STORED_VERSION}" ]; then | ||
| echo "Mozilla TLS data is already at version ${NEW_VERSION}, skipping regeneration." | ||
| exit 0 | ||
| fi | ||
| echo "Updating Mozilla TLS data from version ${STORED_VERSION:-unknown} to ${NEW_VERSION}" | ||
grokspawn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| cat > "${OUTPUT}" <<EOF | ||
| package tlsprofiles | ||
|
|
||
| // DO NOT EDIT, GENERATED BY ${0} | ||
| // DATA SOURCE: ${INPUT} | ||
| // DATA VERSION: ${version} | ||
| // DATA VERSION: ${NEW_VERSION} | ||
|
|
||
| import ( | ||
| "crypto/tls" | ||
| ) | ||
| EOF | ||
|
|
||
| function generate_profile { | ||
| cat >> ${OUTPUT} <<EOF | ||
|
|
||
| var ${1}TLSProfile = tlsProfile{ | ||
| local profile="${1}" | ||
|
|
||
| # Validate the profile key exists before writing any output | ||
| local exists | ||
| exists=$(${JQ} -r ".configurations | has(\"${profile}\")" "${TMPFILE}") | ||
| if [ "${exists}" != "true" ]; then | ||
| echo "ERROR: Profile '${profile}' not found in ${INPUT} (version ${NEW_VERSION})" >&2 | ||
| echo "Available profiles: $(${JQ} -r '.configurations | keys | join(", ")' "${TMPFILE}")" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Validate tls_versions is a non-empty array with a non-null first entry | ||
| if ! ${JQ} -e ".configurations.${profile}.tls_versions | type == \"array\" and length > 0 and .[0] != null" "${TMPFILE}" >/dev/null; then | ||
| echo "ERROR: Missing or empty .configurations.${profile}.tls_versions[0] in ${INPUT}" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Validate that at least one cipher is present across ciphersuites and ciphers.iana | ||
| # (modern has only ciphersuites; intermediate has both; either alone is valid) | ||
| local cipher_count | ||
| cipher_count=$(${JQ} -r " | ||
| [ | ||
| (.configurations.${profile}.ciphersuites // []), | ||
| (.configurations.${profile}.ciphers.iana // []) | ||
| ] | add | length" "${TMPFILE}") | ||
| if [ "${cipher_count}" -eq 0 ] 2>/dev/null; then | ||
| echo "ERROR: Profile '${profile}' has no ciphers in ciphersuites or ciphers.iana" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Validate tls_curves is non-empty | ||
| local curve_count | ||
| curve_count=$(${JQ} -r ".configurations.${profile}.tls_curves | length" "${TMPFILE}") | ||
| if [ "${curve_count}" -eq 0 ] 2>/dev/null; then | ||
| echo "ERROR: Profile '${profile}' has no entries in tls_curves" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| cat >> "${OUTPUT}" <<EOF | ||
|
|
||
| var ${profile}TLSProfile = tlsProfile{ | ||
| ciphers: cipherSlice{ | ||
| cipherNums: []uint16{ | ||
| EOF | ||
|
|
||
| ${JQ} -r ".configurations.$1.ciphersuites.[] | . |= \"tls.\" + . + \",\"" ${TMPFILE} >> ${OUTPUT} | ||
| ${JQ} -r ".configurations.$1.ciphers.iana[] | . |= \"tls.\" + . + \",\"" ${TMPFILE} >> ${OUTPUT} | ||
| ${JQ} -r "(.configurations.${profile}.ciphersuites // [])[] | . |= \"tls.\" + . + \",\"" "${TMPFILE}" >> "${OUTPUT}" | ||
| ${JQ} -r "(.configurations.${profile}.ciphers.iana // [])[] | . |= \"tls.\" + . + \",\"" "${TMPFILE}" >> "${OUTPUT}" | ||
|
|
||
| cat >> ${OUTPUT} <<EOF | ||
| cat >> "${OUTPUT}" <<EOF | ||
| }, | ||
| }, | ||
| curves: curveSlice{ | ||
| curveNums: []tls.CurveID{ | ||
| EOF | ||
|
|
||
| ${JQ} -r ".configurations.$1.tls_curves[] | . |= . + \",\"" ${TMPFILE} >> ${OUTPUT} | ||
| ${JQ} -r ".configurations.${profile}.tls_curves[] | . |= . + \",\"" "${TMPFILE}" >> "${OUTPUT}" | ||
|
|
||
tmshort marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| version=$(${JQ} -r ".configurations.$1.tls_versions[0]" ${TMPFILE}) | ||
| version=$(${JQ} -r ".configurations.${profile}.tls_versions[0]" "${TMPFILE}") | ||
| version=${version/TLSv1./tls.VersionTLS1} | ||
| version=${version/TLSv1/tls.VersionTLS10} | ||
|
|
||
| cat >> ${OUTPUT} <<EOF | ||
| cat >> "${OUTPUT}" <<EOF | ||
| }, | ||
| }, | ||
| minTLSVersion: ${version}, | ||
|
|
@@ -63,11 +123,10 @@ EOF | |
|
|
||
| generate_profile "modern" | ||
| generate_profile "intermediate" | ||
| generate_profile "old" | ||
|
|
||
| # Remove unsupported ciphers from Go's crypto/tls package (Mozilla v5.8 includes these but Go doesn't support them) | ||
| sed -i.bak '/TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384/d; /TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384/d; /TLS_RSA_WITH_AES_256_CBC_SHA256/d' ${OUTPUT} | ||
| rm -f ${OUTPUT}.bak | ||
| # Remove unsupported ciphers from Go's crypto/tls package | ||
| sed -i.bak '/TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384/d; /TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384/d; /TLS_RSA_WITH_AES_256_CBC_SHA256/d' "${OUTPUT}" | ||
| rm -f "${OUTPUT}.bak" | ||
|
|
||
| # Make go happy | ||
| go fmt ${OUTPUT} | ||
| go fmt "${OUTPUT}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package tlsprofiles | ||
|
|
||
| // This file contains a static copy of the Mozilla "old" TLS compatibility profile | ||
| // from version 5.8 of the SSL Configuration Generator. The "old" profile was | ||
| // removed from the Mozilla specification in later versions but is preserved here | ||
| // for backward compatibility with older clients. | ||
| // | ||
| // Source: https://ssl-config.mozilla.org/guidelines/5.8.json | ||
|
|
||
| import "crypto/tls" | ||
|
|
||
| var oldTLSProfile = tlsProfile{ | ||
| ciphers: cipherSlice{ | ||
| cipherNums: []uint16{ | ||
| tls.TLS_AES_128_GCM_SHA256, | ||
| tls.TLS_AES_256_GCM_SHA384, | ||
| tls.TLS_CHACHA20_POLY1305_SHA256, | ||
| tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, | ||
| tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, | ||
| tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, | ||
| tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, | ||
| tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, | ||
| tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, | ||
| tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, | ||
| tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, | ||
| tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, | ||
| tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, | ||
| tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, | ||
| tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, | ||
| tls.TLS_RSA_WITH_AES_128_GCM_SHA256, | ||
| tls.TLS_RSA_WITH_AES_256_GCM_SHA384, | ||
| tls.TLS_RSA_WITH_AES_128_CBC_SHA256, | ||
| tls.TLS_RSA_WITH_AES_128_CBC_SHA, | ||
| tls.TLS_RSA_WITH_AES_256_CBC_SHA, | ||
| tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA, | ||
| }, | ||
| }, | ||
| curves: curveSlice{ | ||
| curveNums: []tls.CurveID{ | ||
| X25519MLKEM768, | ||
| X25519, | ||
| prime256v1, | ||
| secp384r1, | ||
| }, | ||
| }, | ||
| minTLSVersion: tls.VersionTLS10, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.