用 openssl s_client 测试邮件服务器 TLS
与 SMTP/IMAP 服务器完成 STARTTLS 或隐式 TLS 握手,检查证书链是否正常。
运行 openssl s_client -starttls smtp -connect smtp.example.com:587 -brief,握手成功会打印协议版本、加密套件和证书主题。
01命令
命令
$ openssl s_client -starttls smtp -connect smtp.example.com:587 -brief02作用说明
587(发信)和 143(imap)端口的服务器起初是明文连接,靠 STARTTLS 升级加密,所以要用 -starttls smtp(或 imap/pop3)先协商升级;而 465、993 这类隐式 TLS 端口不需要 -starttls 参数。-brief 把输出精简为协商的协议、加密套件和服务器证书的主题/签发者,完整输出里的证书块还能看到有效期。结尾的 'Verify return code: 0 (ok)' 就是快速判断是否通过的信号。
03风险
!注意: s_client 只是展示证书,不做策略强制——证书存在不代表有效,自签名或过期的证书照样能显示,务必看校验码和日期。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- openssl s_client(1) — SSL/TLS client program依据: Man page documents the -starttls option with the smtp protocol value, -connect host:port, and -brief; confirms 's_client' and 'starttls' appear in the text.
- openssl-s_client(1ssl) — Debian man page依据: Man page text includes -starttls with protocol values smtp/pop3/imap and -brief option, confirming the flags used.
最后验证: 2026-09-19 · 分类: 安全与隐私