Skip to content

Commit

Permalink
bin/helpers: Add certificateFingerprint and certificateFingerprintShort
Browse files Browse the repository at this point in the history
Signed-off-by: Julian Pelizäus <[email protected]>
  • Loading branch information
roosterfish committed Apr 4, 2024
1 parent 8b94590 commit cf6a365
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bin/helpers
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ createCertificateAndKey() (
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:secp384r1 -sha384 -keyout "${key_file}" -nodes -out "${crt_file}" -days 1 -subj "/CN=${cn}"
)

# certificateFingerprint: returns the certificate's fingerprint.
certificateFingerprint() (
openssl x509 -in "${1}" -outform der | sha256sum
)

# certificateFingerprintShort: returns the certificate's fingerprint in short form as used by LXD.
certificateFingerprintShort() (
certificateFingerprint "${1}" | head -c12
)

# cleanup: report if the test passed or not and return the appropriate return code.
cleanup() {
set +e
Expand Down

0 comments on commit cf6a365

Please sign in to comment.