cevincheung
V2EX  ›  PHP

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

  •  
  •   cevincheung · Oct 21, 2015 · 3231 views
    This topic created in 3941 days ago, the information mentioned may be changed or developed.

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

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

    9 replies    2015-10-24 10:58:26 +08:00
    vitovan
        1
    vitovan  
       Oct 21, 2015
    翻首页干啥?为什么不去翻文档?
    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  
       Oct 22, 2015 via Android
    他问的是如何 pin 住证书。
    alect
        4
    alect  
       Oct 22, 2015
    然而,程序写死不是一个明智的选择。。万一真的被人破了密钥,完蛋咯。
    chuxiwen
        5
    chuxiwen  
       Oct 22, 2015 via iPad
    man curl
    oott123
        6
    oott123  
       Oct 22, 2015 via Android
    其实楼主问的是 PHP
    我不会告诉楼主 php 文档里也有的
    cevincheung
        7
    cevincheung  
    OP
       Oct 22, 2015
    @oott123 @.@ 哪里?

    不要告诉我是 CAINFO ...
    realpg
        8
    realpg  
       Oct 24, 2015
    @cevincheung
    所有 curl 命令行能附加参数实现的东西
    基本去 curl_setopt 里找都有
    http://php.net/manual/en/function.curl-setopt.php
    cevincheung
        9
    cevincheung  
    OP
       Oct 24, 2015
    @realpg 然而翻烂了手册也没找到有关 PINNING 的任何资料。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5491 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 07:17 · PVG 15:17 · LAX 00:17 · JFK 03:17
    ♥ Do have faith in what you're doing.