Skip to content

Commit 486bc40

Browse files
markshusth3xx
andauthored
Merge from master (#1306)
Co-authored-by: Dan Church <h3xx@users.noreply.github.com>
1 parent bbd2e3e commit 486bc40

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

compose/bin/setup-ssl-ca

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,38 @@ echo "System password requested to install certificate authority on host..."
88

99
if [ "$(uname)" == "Darwin" ]; then
1010
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain rootCA.pem
11+
echo "{\"policies\": {\"Certificates\": {\"ImportEnterpriseRoots\": true}}}" | sudo tee policies.json
1112

13+
FIREFOX_FOUND=0
1214
### Check if Firefox is installed
13-
FFoxBin="/Applications/Firefox.app/Contents/MacOS/firefox-bin"
14-
if [ -f "$FFoxBin" ]; then
15-
echo "{\"policies\": {\"Certificates\": {\"ImportEnterpriseRoots\": true}}}" | sudo tee policies.json
15+
for FFoxAppDir in \
16+
'/Applications/Firefox.app' \
17+
'/Applications/Firefox Developer Edition.app' \
18+
; do
1619

17-
### Check if distribution directory exists
18-
DistDirectory="/Applications/Firefox.app/Contents/Resources/distribution"
19-
if [ ! -d "$DistDirectory" ]; then
20+
FFoxBin=$FFoxAppDir/Contents/MacOS/firefox-bin
21+
if [[ -f $FFoxBin ]]; then
22+
printf 'Firefox compatible found at: %s\n' "$FFoxAppDir" >&2
23+
FIREFOX_FOUND=1
24+
25+
### Copy the newly created policies.json to the Certificates directory
26+
DistDirectory=$FFoxAppDir/Contents/Resources/distribution
2027
sudo mkdir -p "$DistDirectory"
21-
fi
22-
### Move the newly created policies.json to the Certificates directory
23-
sudo mv policies.json "$DistDirectory"/policies.json
28+
sudo cp policies.json "$DistDirectory"/policies.json
2429

25-
### Check if Certificates directory exists
26-
CertDirectory="/Library/Application Support/Mozilla/Certificates"
27-
if [ ! -d "$CertDirectory" ]; then
28-
sudo mkdir -p "$CertDirectory"
2930
fi
31+
done
3032

31-
### Move the newly created .pem to the Certificates directory
32-
sudo mv rootCA.pem "$CertDirectory"/rootCA.pem
33-
else
34-
sudo rm rootCA.pem
33+
if [[ $FIREFOX_FOUND -ne 0 ]]; then
34+
### Copy the newly created .pem to the Certificates directory
35+
CertDirectory='/Library/Application Support/Mozilla/Certificates'
36+
printf 'Installing CA certificate to: %s\n' "$CertDirectory" >&2
37+
sudo mkdir -p "$CertDirectory"
38+
sudo cp rootCA.pem "$CertDirectory"/rootCA.pem
3539
fi
3640

41+
rm -f policies.json rootCA.pem
42+
3743
else
3844

3945
### Requirement: apt install libnss3-tools

0 commit comments

Comments
 (0)