Skip to content

Commit

Permalink
fix: Use subject hash for openssl macro test (#267)
Browse files Browse the repository at this point in the history
The subject output appears to have changed in more recent OpenSSL versions, but the hash algorithm has been stable since OpenSSL 1.0.0.
  • Loading branch information
SanjayVas authored Sep 3, 2024
1 parent 4130f10 commit 0be1ce0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions build/openssl/generate_root_certificate_validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ readonly CERT_PATH="${TESTDATA_DIR}/test_root.pem"
readonly KEY_PATH="${TESTDATA_DIR}/test_root.key"
readonly ORG='Some Organization'
readonly COMMON_NAME='Some CA'
readonly SUBJECT="subject=O = ${ORG}, CN = ${COMMON_NAME}"
readonly SUBJECT_HASH='e65a7621'
readonly HOSTNAME='ca.someorg.example.com'

err() {
Expand All @@ -61,10 +61,10 @@ main() {
fi

# Check the certificate details
local subject
subject="$(openssl x509 -in "${cert_file}" -noout -subject)"
if [[ "${subject}" != "${SUBJECT}" ]]; then
err "Not true that ${subject} is equal to ${SUBJECT}"
local subject_hash
subject_hash="$(openssl x509 -in "${cert_file}" -noout -subject_hash)"
if [[ "${subject_hash}" != "${SUBJECT_HASH}" ]]; then
err "Not true that subject hash ${subject_hash} is equal to ${SUBJECT_HASH}"
exit 1
fi
}
Expand Down
10 changes: 5 additions & 5 deletions build/openssl/generate_user_certificate_validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ readonly CERT_PATH="${TESTDATA_DIR}/test_user.pem"
readonly KEY_PATH="${TESTDATA_DIR}/test_user.key"
readonly ORG='Some Organization'
readonly COMMON_NAME='Some Server'
readonly SUBJECT="subject=O = ${ORG}, CN = ${COMMON_NAME}"
readonly SUBJECT_HASH='bf3afa36'
readonly HOSTNAME='server.someorg.example.com'

err() {
Expand Down Expand Up @@ -67,10 +67,10 @@ main() {
fi

# Check the certificate details
local subject
subject="$(openssl x509 -in "${cert_file}" -noout -subject)"
if [[ "${subject}" != "${SUBJECT}" ]]; then
err "Not true that ${subject} is equal to ${SUBJECT}"
local subject_hash
subject_hash="$(openssl x509 -in "${cert_file}" -noout -subject_hash)"
if [[ "${subject_hash}" != "${SUBJECT_HASH}" ]]; then
err "Not true that subject hash ${subject_hash} is equal to ${SUBJECT_HASH}"
exit 1
fi
}
Expand Down

0 comments on commit 0be1ce0

Please sign in to comment.