zoukankan      html  css  js  c++  java
  • php curl时遇到Can't load the certificate "..." and its private key: OSStatus -25299的问题

    https://cloud.tencent.com/developer/article/1199278

    php在执行curl 使用私钥访问https网站时, 提示Can't load the certificate "..." and its private key: OSStatus -25299, 在此之前还有提示其他类似的错误, 应该都是因为php中curl的SSL Version中不是OpenSSL的问题

    基本环境: MAC OS X、php5.6

    phpinfo()查看curl信息, 显示的SSL Version 不是OpenSSL(在linux可能也显示别的)

    一、先查看系统的curl支持的协议

    >>> curl -V
    curl 7.56.1 (x86_64-apple-darwin15.3.0) libcurl/7.56.1 OpenSSL/1.0.2m zlib/1.2.5
    Release-Date: 2017-10-23
    Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
    Features: AsynchDNS IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP UnixSockets HTTPS-proxy

    如果返回的信息里没有OpenSSL, 则需要重新安装一个新的curl, 查看第二步, 如果有OpenSSL, 则直接看第三步

    二、重新安装curl

    >>> brew uninstall curl
    >>> brew install curl --with-openssl
    >>> brew link curl --force
    >>> curl --version

    三、重新安装php

    >>> brew uninstall php56
    >>> brew install --with-homebrew-curl php56

    四、重启服务, 查看phpinfo中的SSL VERSION 是否是OpenSSL

    https://my.oschina.net/tridays/blog/857872

    这是在 mac 下 curl 使用 pem 证书时发生的问题。原因是 iOS/macOS 的默认 SSL 实现 Secure Transport 在指定证书字符串时只允许使用系统或用户钥匙串(Keychain)中的名称或 PKCS#12 编码的证书和密钥。

    另外,如果使用的是当前目录下的文件最好使用“./”前缀,避免与钥匙串中的别名冲突。

    如何查看自己在使用的 curl 的情况呢,使用 curl --version

    # curl with SecureTransport
    $ curl --version
    curl 7.51.0 (x86_64-apple-darwin16.0) libcurl/7.51.0 SecureTransport zlib/1.2.8
    Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
    Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets
    
    # curl with OpenSSL
    curl 7.53.1 (x86_64-apple-darwin16.4.0) libcurl/7.53.1 OpenSSL/1.0.2k zlib/1.2.8
    Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
    Features: IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP UnixSockets HTTPS-proxy
    

    可以明显看到两者的区别。

    我们可以使用 Homebrew 来安装 curl with OpenSSL:

    $ brew unlink curl
    $ brew install curl --with-openssl
    $ brew link curl --force
    
    # 记得在环境变量 PATH 中将 /usr/local/bin 放于 /usr/bin 之前
    $ which curl
    /usr/local/bin/curl
    

    相关资料:

  • 相关阅读:
    查看DNS、IP、Mac等
    windows测试物理网络
    ACCEPT详解
    oracle动静视图-权限-角色-参数
    [ PHP+jQuery ] ajax 多级联动菜单的应用:电商网站的用户地址选择功能 ( 二 )
    使用Python爬取网页的相关内容(图片,文字,链接等等)
    使用Python爬取网页的相关内容(图片,文字,链接等等)
    使用Pycharm安装插件时发生错误
    使用Pycharm安装插件时发生错误
    使用Pycharm安装插件时发生错误
  • 原文地址:https://www.cnblogs.com/rxbook/p/14276255.html
Copyright © 2011-2022 走看看