Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Generate certificates for domains were in Warden #44

Merged
merged 2 commits into from
Aug 31, 2022
Merged
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
14 changes: 13 additions & 1 deletion commands/install.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if [[ "$OSTYPE" =~ ^linux ]] \
&& [[ ! -f /etc/pki/ca-trust/source/anchors/den-proxy-local-ca.cert.pem ]] \
## Fedora/CentOS
then
echo "==> Trusting root certificate (requires sudo privileges)"
echo "==> Trusting root certificate (requires sudo privileges)"
sudo cp "${WARDEN_SSL_DIR}/rootca/certs/ca.cert.pem" /etc/pki/ca-trust/source/anchors/den-proxy-local-ca.cert.pem
sudo update-ca-trust
elif [[ "$OSTYPE" =~ ^linux ]] \
Expand All @@ -51,6 +51,18 @@ then
-k /Library/Keychains/System.keychain "${WARDEN_SSL_DIR}/rootca/certs/ca.cert.pem"
fi

# Migration from Warden - Generate certificates for domains were there
if [[ -d ~/.warden/ssl/certs/ ]]; then
domains_to_generate="$(diff -B <(ls ~/.den/ssl/certs/ | grep .key.pem | sed 's/.key.pem//' | grep -v warden.test) <(ls ~/.warden/ssl/certs/ | grep .key.pem | sed 's/.key.pem//' | grep -v warden.test) | grep '^>' | sed 's/^>\ //')"
if [[ -n "$domains_to_generate" ]]; then
echo "Generating certificates present in Warden..."

echo "$domains_to_generate" | while read i; do
den sign-certificate "$i"
done
fi
fi

## configure resolver for .test domains on Mac OS only as Linux lacks support
## for BSD like per-TLD configuration as is done at /etc/resolver/test on Mac
if [[ "$OSTYPE" == "darwin"* ]]; then
Expand Down