Interview Prep/Shell Scripting/Troubleshooting: tools, portability, permissions and environment

Behind the corporate proxy, the alert script fails with `curl: (60) SSL certificate problem: unable to get local issuer certificate`. Someone suggests adding `-k`.

IntermediateTroubleshootingTroubleshooting: tools, portability, permissions and environment
Answer

Likely causes → A TLS-inspecting proxy re-signs HTTPS traffic with the company's own CA, which is not in the host's trust store. Less often, the server sends an incomplete certificate chain. -k disables verification entirely, so the webhook URL (a secret) could be sent to anyone who intercepts the connection.

Diagnose →

curl -v https://hooks.slack.com 2>&1 | grep -E 'issuer|subject'           # issuer is the corporate CA?
openssl s_client -connect hooks.slack.com:443 -showcerts </dev/null 2>/dev/null | grep -E 's:|i:'
env | grep -i _proxy

Fix → Trust the corporate CA system-wide, or point curl at a bundle:

sudo cp corp-root-ca.crt /usr/local/share/ca-certificates/ && sudo update-ca-certificates   # Debian/Ubuntu
sudo cp corp-root-ca.crt /etc/pki/ca-trust/source/anchors/ && sudo update-ca-trust           # RHEL family
curl --cacert /etc/opskit/corp-ca.pem ...                                                    # per-call

Prevent → Bake the CA into base images; fail CI on any curl -k/--insecure in scripts (grep -rnE 'curl .*(-k|--insecure)' scripts/).

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Troubleshooting: tools, portability, permissions and environment