cevincheung
V2EX  ›  PHP

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

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

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

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

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

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