话说 curl 怎么使用指定 [公钥] 去跟对方服务器通信?

2015-10-21 19:46:38 +08:00
 cevincheung

关于中间人攻击,替换服务器公钥。想在程序里写死公钥,对方服务器发过来的公钥与写死的不一致就终止通信。

然而翻烂了首页也没发现有什么方法可以实现的。

2627 次点击
所在节点    PHP
9 条回复
vitovan
2015-10-21 21:39:21 +08:00
翻首页干啥?为什么不去翻文档?
http://curl.haxx.se/docs/httpscripting.html#Certificates

At times you may end up with your own CA cert store and then you can tell curl to use that to verify the server's certificate:
curl --cacert ca-bundle.pem https://example.com/
snnn
2015-10-22 00:15:24 +08:00
他问的是如何 pin 住证书。
msg7086
2015-10-22 05:39:28 +08:00
alect
2015-10-22 07:42:08 +08:00
然而,程序写死不是一个明智的选择。。万一真的被人破了密钥,完蛋咯。
chuxiwen
2015-10-22 10:39:00 +08:00
man curl
oott123
2015-10-22 12:21:38 +08:00
其实楼主问的是 PHP
我不会告诉楼主 php 文档里也有的
cevincheung
2015-10-22 12:56:37 +08:00
@oott123 @.@ 哪里?

不要告诉我是 CAINFO ...
realpg
2015-10-24 09:37:03 +08:00
@cevincheung
所有 curl 命令行能附加参数实现的东西
基本去 curl_setopt 里找都有
http://php.net/manual/en/function.curl-setopt.php
cevincheung
2015-10-24 10:58:26 +08:00
@realpg 然而翻烂了手册也没找到有关 PINNING 的任何资料。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/229963

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX