Skip to content

Commit

Permalink
Merge pull request #291 from terrateamio/CHE-13/http-proxy-add-self-s…
Browse files Browse the repository at this point in the history
…igned-certs

ADD trust-cert script to add cert to cert store
  • Loading branch information
bender2352 authored Jul 10, 2024
2 parents de6f317 + 95d21bf commit c0af905
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions bin/trust-cert
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

0 comments on commit c0af905

Please sign in to comment.