Skip to content

Commit

Permalink
refactor: use openssl to inspect the certificate before deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Feb 11, 2024
1 parent aed0cb8 commit efab999
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion legacy/build-deploy-docker-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1932,7 +1932,10 @@ for TLS_FALSE_INGRESS in $TLS_FALSE_INGRESSES; do
TLS_SECRETS=$(kubectl -n ${NAMESPACE} get ingress ${TLS_FALSE_INGRESS} -o json | jq -r '.spec.tls[]?.secretName')
for TLS_SECRET in $TLS_SECRETS; do
echo ">> Cleaning up certificate for ${TLS_SECRET} as tls-acme is set to false"
kubectl -n ${NAMESPACE} delete secret ${TLS_SECRET}-tls
# check if it is a lets encrypt certificate
if openssl x509 -in <(kubectl -n ${NAMESPACE} get secret ${TLS_SECRET}-tls -o json | jq -r '.data."tls.crt"' | base64 --decode) -text -noout | grep -o -q "Let's Encrypt" s &> /dev/null; then
kubectl -n ${NAMESPACE} delete secret ${TLS_SECRET}-tls
fi
if kubectl -n ${NAMESPACE} get certificates.cert-manager.io ${TLS_SECRET} &> /dev/null; then
kubectl -n ${NAMESPACE} delete certificates.cert-manager.io ${TLS_SECRET}
fi
Expand Down

0 comments on commit efab999

Please sign in to comment.