检测服务器支持SSL的版本

检测服务器支持SSL的版本

使用第三方服务

https://myssl.com/
https://www.ssllabs.com/

使用PowerShell测试

[System.Net.ServicePointManager]::SecurityProtocol=[System.Net.SecurityProtocolType]::Ssl3 
curl https://www.baidu.com

[System.Net.ServicePointManager]::SecurityProtocol=[System.Net.SecurityProtocolType]::Tls 
curl https://www.baidu.com

[System.Net.ServicePointManager]::SecurityProtocol=[System.Net.SecurityProtocolType]::Tls11 
curl https://www.baidu.com

[System.Net.ServicePointManager]::SecurityProtocol=[System.Net.SecurityProtocolType]::Tls12 
curl https://www.baidu.com

使用curl工具

curl -v --tlsv1.0 https://www.baidu.com
curl -v --tlsv1.1 https://www.baidu.com
curl -v --tlsv1.2 https://www.baidu.com

此工具会出现服务端不支持tlsv1.0,却能使用curl -v --tlsv1.0 https://www.baidu.com 访问成功的现象。
这种问题的原因是 curl工具本身,curl --help 查看关于 --tlsv1.0参数的介绍如果有 *** or greater 则即使明确使用tls1.0,如果服务器不支持tls1.0 ,curl工具也会自动切换到高版本尝试,具体可以使用 -v参数 查看详情。
curl是否自动切换,不同版本,curl --help 的介绍也不同。

参考

SecurityProtocolType 枚举
SecurityProtocol 属性

posted @ 2021-02-25 16:17  hiyn  阅读(3256)  评论(0)    收藏  举报