Skip to content

Commit

Permalink
Merge pull request #292 from terrateamio/main
Browse files Browse the repository at this point in the history
Release v1
  • Loading branch information
bender2352 authored Jul 10, 2024
2 parents 872e0d7 + c0af905 commit f48c65c
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 f48c65c

Please sign in to comment.