dtttlua7165 2018-05-14 12:38
浏览 76
已采纳

PHP 5.3中的默认CA证书位置

How can I find the default CA certificate locations used by PHP 5.3? In PHP 5.6 and above, there is the function openssl_get_cert_locations that can answer this question. But what would be the equivalent in PHP 5.3?

  • 写回答

1条回答 默认 最新

  • douxie1894 2018-05-14 13:18
    关注

    As of PHP 5.6 it will automatically determine where your CA certificates are located. Ideally you should update to a newer version of PHP (7.1 would be a good target to upgrade to).

    Here are the links to the specific RFCs which cover the topic in more depth and explain why and how the changes were made in PHP >= 5.6:

    For anything before PHP 5.6 you'll need to manually specify them (either by locating them yourself and manually specifying them or download a prepackaged set from a source like https://curl.haxx.se/ca/cacert.pem and add it to your code repository).

    Then manually specify it in your code like this:

    // Using cURL
    curl_setopt($curl, CURLOPT_CAINFO, 'path/to/cafile');
    
    // or using file_get_contents
    $context = stream_context_create([
        'ssl' => [
            'verify_peer' => true,
            'cafile'      => 'path/to/cafile',
            'CN_match'    => '[domain-you-are-contecting-to]'
        ]
    ]);
    file_get_contents($url, false, $context);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部