Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions integration-tests/macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ ANY_CA_PEM=integration-tests/one-existing-ca.pem
ANY_CA_SUBJECT="OU=GlobalSign Root CA - R3, O=GlobalSign, CN=GlobalSign"

reset() {
security remove-trusted-cert -d $ANY_CA_PEM || true
list | grep "$ANY_CA_SUBJECT"
printf "\n*** Remove test CA ***\n"
CERT_HASH=$(openssl x509 -in $ANY_CA_PEM -noout -fingerprint -sha1 | cut -d= -f2 | tr -d :)
security delete-certificate -Z "$CERT_HASH" /Library/Keychains/System.keychain || true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this tidying up is not actually worth it. How about deleting reset and all calls to it? I assume GHA gives a fresh, fixed environment for every job run anyway...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the goal here was to be able to run it on your local machine, in which case leaving it in the same state it came in would be useful...

assert_missing "$ANY_CA_SUBJECT"
}

list() {
Expand All @@ -28,12 +30,14 @@ assert_exists() {

test_distrust_existing_root() {
assert_exists "$ANY_CA_SUBJECT"
printf "\n*** Add test CA ***\n"
security add-trusted-cert -d -r deny $ANY_CA_PEM
assert_missing "$ANY_CA_SUBJECT"
reset
}

# https://developer.apple.com/forums/thread/671582?answerId=693632022#693632022
printf "\n*** Enable trust settings ***\n"
security authorizationdb write com.apple.trust-settings.admin allow

reset
Expand Down
Loading