Created
November 19, 2025 15:14
-
-
Save lcgogo/547a8896e270771cac83c91f2715e144 to your computer and use it in GitHub Desktop.
fix alpine 3.19+ ca error
This file contains hidden or 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
| #!/bin/sh | |
| set -e | |
| DOMAIN="api.cobo.com" | |
| CERT_DIR="/usr/local/share/ca-certificates" | |
| CERT_FILE="$CERT_DIR/cobo_intermediate.crt" | |
| echo "π Fetching certificate chain from $DOMAIN ..." | |
| openssl s_client -showcerts -connect $DOMAIN:443 </dev/null 2>/tmp/cert_debug.log \ | |
| | awk '/BEGIN CERTIFICATE/,/END CERTIFICATE/' > /tmp/fullchain.pem | |
| echo "π Extracting intermediate certificate ..." | |
| awk 'BEGIN {c=0} | |
| /BEGIN CERTIFICATE/ { | |
| c++ | |
| filename="/tmp/cert_" c ".pem" | |
| } | |
| { | |
| print > filename | |
| } | |
| /END CERTIFICATE/ { close(filename) }' < /tmp/fullchain.pem | |
| # Usually intermediate cert is cert_2.pem | |
| if [ -f /tmp/cert_2.pem ]; then | |
| cp /tmp/cert_2.pem "$CERT_FILE" | |
| else | |
| echo "β No intermediate cert found, using cert_1.pem instead" | |
| cp /tmp/cert_1.pem "$CERT_FILE" | |
| fi | |
| echo "π Installing intermediate CA into system trust store ..." | |
| update-ca-certificates | |
| echo "π Verifying..." | |
| curl -v https://$DOMAIN --max-time 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment