-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #291 from terrateamio/CHE-13/http-proxy-add-self-s…
…igned-certs ADD trust-cert script to add cert to cert store
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,25 @@ | ||
#!/usr/bin/env bash | ||
set -euf -o pipefail | ||
|
||
# Check if at least one domain is provided as an argument | ||
if [ "$#" -eq 0 ]; then | ||
echo "Usage: $0 domain1 [domain2 ... domainN]" | ||
exit 1 | ||
fi | ||
|
||
# Iterate over each provided domain | ||
for domain in "$@"; do | ||
echo "Retrieving certificate for $domain..." | ||
|
||
# Use openssl to retrieve the certificate and save it to the appropriate directory | ||
openssl s_client -showcerts -connect "$domain:443" < /dev/null | \ | ||
sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > "/usr/local/share/ca-certificates/${domain}.crt" | ||
done | ||
|
||
# Update the system's certificate store | ||
update-ca-certificates | ||
|
||
echo "Certificates updated successfully." | ||
|
||
# Example usage: | ||
# ./trust-cert example.com example.org example.net |