命令行访问https(转载,略有改动)
由于现在很多的互联网页面开始使用https,造成telnet 的http方式无法访问(文档地址:用Telnet发送HTTP请求),特补充下文:
1、安装openssl。如链接失效,请自行找其它资源。
2、将openssl 的bin目录(D:\Program Files\OpenSSL-Win64\bin)加入系统环境变量Path中。
3、使用命令访问
openssl s_client -connect www.baidu.com:443
返回证书信息类似下文:
CONNECTED(000001A0)
depth=1 C = BE, O = GlobalSign nv-sa, CN = GlobalSign Organization Validation CA – SHA256 – G2
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 C = CN, ST = beijing, L = beijing, OU = service operation department, O = “Beijing Baidu Netcom Science Technology Co., Ltd”, CN = baidu.com
verify return:1
—
Certificate chain
0 s:C = CN, ST = beijing, L = beijing, OU = service operation department, O = “Beijing Baidu Netcom Science Technology Co., Ltd”, CN = baidu.com
i:C = BE, O = GlobalSign nv-sa, CN = GlobalSign Organization Validation CA – SHA256 – G2
1 s:C = BE, O = GlobalSign nv-sa, CN = GlobalSign Organization Validation CA – SHA256 – G2
i:C = BE, O = GlobalSign nv-sa, OU = Root CA, CN = GlobalSign Root CA
—
Server certificate…..
GET / HTTP/1.1 HOST: www.baidu.com /*这句话可不要*/
再连续按两次回车键,该命令表示向baidu索要首页根文件,使用的协议是HTTP的1.1版本。
返回网页代码如下:
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: no-cache
Connection: Keep-Alive
Content-Length: 14722
Content-Type: text/html
Date: Thu, 17 Oct 2019 08:52:58 GMT
P3p: CP=” OTI DSP COR IVA OUR IND COM “
P3p: CP=” OTI DSP COR IVA OUR IND COM “
Pragma: no-cache
Server: BWS/1.1
Set-Cookie: BAIDUID=DCFC93ADF1F24B901BE236D73D94F686:FG=1; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com
Set-Cookie: BIDUPSID=DCFC93ADF1F24B901BE236D73D94F686; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.b…
其它内容可以参考 用Telnet发送HTTP请求