openssl s_client 命令——测试、调试和诊断 SSL/TLS 连接
目录
- openssl s_client 命令详解
-
- 基本语法
- 常用参数详解
-
- 连接参数
- 证书相关参数
- 协议版本控制
- 调试和信息输出
- 其他重要参数
- 输出信息解读
-
- 典型成功输出包含:
- 重要返回码:
- 交互模式
- 实用示例
-
- 1. 基本 SSL 连接测试
- 2. 详细调试连接
- 3. 测试特定协议版本
- 4. 证书验证测试
- 5. SNI(服务器名称指示)测试
- 6. 测试特定加密套件
- 7. STARTTLS 测试(用于 SMTP、POP3 等)
- 8. 客户端证书认证
- 9. 会话重用测试
- 故障诊断技巧
-
- 1. 检查连接问题
- 2. 检查协议支持
- 3. 验证证书链
- 安全注意事项
openssl s_client 命令详解
openssl s_client
是一个功能强大的 SSL/TLS 客户端工具,用于测试、调试和诊断 SSL/TLS 连接。
基本语法
openssl s_client [options] [host:port]
常用参数详解
连接参数
-connect <目标主机:目标端口>
- 指定要连接的远程服务器
# 基本用法
openssl s_client -connect example.com:443# 连接本地服务
openssl s_client -connect localhost:8443# 使用 IP 地址
openssl s_client -connect 192.168.1.100:443
-bind <本地IP:本地端口>
- 指定客户端使用的哪个本地源地址和端口
# 绑定到特定本地 IP
openssl s_client -connect example.com:443 -bind 192.168.1.50:0# 绑定到特定本地端口
openssl s_client -connect example.com:443 -bind 0.0.0.0:12345# 绑定到具体 IP 和端口
openssl s_client -connect example.com:443 -bind 192.168.1.50:54321
注意事项:
- :0
表示让系统自动选择可用端口
- 0.0.0.0
表示绑定到所有本地接口
- 必须确保绑定的 IP 地址在本地系统上已配置且可用
-proxy <目标代理:本地端口>
- 通过 HTTP 代理连接
# 通过代理连接
openssl s_client -connect example.com:443 -prox