V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
cevincheung
V2EX  ›  PHP

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

  •  
  •   cevincheung · 2015-10-21 19:46:38 +08:00 · 2618 次点击
    这是一个创建于 3110 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

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

    9 条回复    2015-10-24 10:58:26 +08:00
    vitovan
        1
    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
        2
    snnn  
       2015-10-22 00:15:24 +08:00 via Android
    他问的是如何 pin 住证书。
    msg7086
        3
    msg7086  
       2015-10-22 05:39:28 +08:00
    alect
        4
    alect  
       2015-10-22 07:42:08 +08:00
    然而,程序写死不是一个明智的选择。。万一真的被人破了密钥,完蛋咯。
    chuxiwen
        5
    chuxiwen  
       2015-10-22 10:39:00 +08:00 via iPad
    man curl
    oott123
        6
    oott123  
       2015-10-22 12:21:38 +08:00 via Android
    其实楼主问的是 PHP
    我不会告诉楼主 php 文档里也有的
    cevincheung
        7
    cevincheung  
    OP
       2015-10-22 12:56:37 +08:00
    @oott123 @.@ 哪里?

    不要告诉我是 CAINFO ...
    realpg
        8
    realpg  
       2015-10-24 09:37:03 +08:00
    @cevincheung
    所有 curl 命令行能附加参数实现的东西
    基本去 curl_setopt 里找都有
    http://php.net/manual/en/function.curl-setopt.php
    cevincheung
        9
    cevincheung  
    OP
       2015-10-24 10:58:26 +08:00
    @realpg 然而翻烂了手册也没找到有关 PINNING 的任何资料。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2833 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 06:20 · PVG 14:20 · LAX 23:20 · JFK 02:20
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.