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

2015 年 10 月 21 日
 cevincheung

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

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

3275 次点击
所在节点    PHP
9 条回复
vitovan
2015 年 10 月 21 日
翻首页干啥?为什么不去翻文档?
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 日
他问的是如何 pin 住证书。
msg7086
2015 年 10 月 22 日
alect
2015 年 10 月 22 日
然而,程序写死不是一个明智的选择。。万一真的被人破了密钥,完蛋咯。
chuxiwen
2015 年 10 月 22 日
man curl
oott123
2015 年 10 月 22 日
其实楼主问的是 PHP
我不会告诉楼主 php 文档里也有的
cevincheung
2015 年 10 月 22 日
@oott123 @.@ 哪里?

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

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

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

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

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

© 2021 V2EX