【发布时间】:2021-02-08 10:35:15
【问题描述】:
我有这个代码
$ curl "https://api.weixin.qq.com:443/sns/jscode2session?appid=a&secret=b&js_code=c&grant_type=authorization_code"
它可以像下面这样从服务器获得响应
{"errcode":40013,"errmsg":"invalid appid rid: 5f96703e-5e24e4f1-691a9221"}
但是,当我尝试将主机名替换为 ip 时,失败并显示以下消息
$ host api.weixin.qq.com
api.weixin.qq.com has address 180.97.7.108
api.weixin.qq.com has address 101.226.212.27
$ curl "https://101.226.212.27:443/sns/jscode2session?appid=a&secret=b&js_code=c&grant_type=authorization_code"
curl: (60) SSL: no alternative certificate subject name matches target host name '101.226.212.27'
More details here: https://curl.haxx.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
我需要添加 -k 来完成这项工作
$ curl "https://101.226.212.27:443/sns/jscode2session?appid=a&secret=b&js_code=c&grant_type=authorization_code" -k
{"errcode":40013,"errmsg":"invalid appid rid: 5f967132-1ee77e4b-2f378192"}c
我想知道为什么会发生这种情况,以及这里是否存在任何安全问题?如果有的话,我怎样才能删除这个-k 标志?
【问题讨论】: