排查 Linux 下 OpenSSL 问题通常可以按「现象 → 定位 → 验证」的思路进行。下面给你一套实用排查清单,覆盖常见场景(证书、连接、版本、编译、库冲突等)。
openssl version
which openssl
⚠️ 注意:
/usr/bin/openssl/usr/local/openssl/bin/openssl)ldd $(which openssl)
常见问题:
libssl.so / libcrypto.so 找不到openssl verify -CAfile ca.pem server.pem
openssl x509 -in cert.pem -noout -text
openssl x509 -in cert.pem -noout -dates
| 错误 | 原因 |
|---|---|
unable to get local issuer certificate |
CA 未配置 |
certificate has expired |
证书过期 |
hostname mismatch |
CN / SAN 不匹配 |
openssl s_client -connect example.com:443
查看:
openssl s_client -connect host:443 -tls1_2
openssl s_client -connect host:443 -tls1_3
| 现象 | 排查点 |
|---|---|
connection refused |
防火墙 / 服务未启动 |
handshake failure |
协议或 cipher 不匹配 |
no shared cipher |
服务端配置问题 |
ldd your_program | grep ssl
常见问题:
解决:
LD_LIBRARY_PATH=/path/to/openssl/lib ./your_program
grep OPENSSL_VERSION_TEXT /usr/include/openssl/opensslv.h
| 错误 | 原因 |
|---|---|
undefined reference to SSL_* |
没链接 -lssl -lcrypto |
openssl/xxx.h not found |
头文件路径不对 |
export OPENSSL_CONF=/dev/null
openssl s_client -debug ...
journalctl -u your_service
dmesg | tail
如果你有具体报错信息(如 SSL_ERROR_*、程序崩溃、握手失败),可以直接贴出来,我可以帮你精确定位。