PHP CURL“NSS:找不到客户端证书(昵称未指定)”问题

时间:2017-07-05 16:17:51

标签: php ssl curl https nss

对我的某个服务器上的单个特定https端点的请求失败,并且PHP CURL中出现“NSS:找不到客户端证书(未指定昵称)”错误。

当我使用verbose选项从命令行运行相同的查询时,我得到了相同的错误,但之后我也得到了一个有效的响应(在相同的CURL请求中出错之后)。

然后我为我的PHP CURL请求启用了verbose选项并显示它以进行测试:

$error = curl_error($curl);

if ($error) {
        echo "cURL Error #:" . $error;

        rewind($verbose);
        $verboseLog = htmlspecialchars(stream_get_contents($verbose));

        echo "<pre>";
        print_r($verboseLog);
} else {
  echo $response;
}

并将此作为输出:

cURL Error #:NSS: client certificate not found (nickname not specified)
* About to connect() to <address> port 8001 (#0)
*   Trying <ip>... * connected
* Connected to <address> (<ip>) port 8001 (#0)
* skipping SSL peer certificate verification
* NSS: client certificate not found (nickname not specified)
* SSL connection using TLS_RSA_WITH_AES_128_GCM_SHA256
* Server certificate:
*   subject: CN=*.<address>m,O=XXX A.S.,OU=IT,L=Umraniye,ST=Istanbul,C=TR
*   start date: Jun 11 12:52:03 2015 GMT
*   expire date: Jun 09 14:16:13 2018 GMT
*   common name: *.<address>
*   issuer: CN=GlobalSign Organization Validation CA - SHA256 - G2,O=GlobalSign nv-sa,C=BE
> POST /<url_part> HTTP/1.1
Host: <address>:8001
Accept: */*
Accept-Encoding: deflate, gzip
authorization: Basic UlBlahBlahnJrcjEyMzQ1Ng==
cache-control: no-cache
content-type: application/json
postman-token: eeefe018-7cac-1706-7b6d-847800a7ad0f
Content-Length: 333

< HTTP/1.1 200 OK
< set-cookie: sap-usercontext=sap-client=100; path=/
< set-cookie: SAP_SESSIONID_CFP_100=ohZvfO5ZOwq_LTE76Zgz9L-C0NdhlRHngM0AF6R3IFY%3d; path=/
< content-type: application/json; charset=utf-8
< content-length: 1150
< cache-control: max-age=0
< sap-cache-control: +180 
< sap-isc-uagent: 0
< 
* Connection #0 to host <address> left intact
* Closing connection #0

因此,CURL请求以错误结束,但在详细日志中,我们看到在获取错误有效响应之后也是如此。

这是我的问题:

  1. 只要其他不同的https端点完全正常工作,有没有办法克服这个NSS问题?它是否与端点的服务器配置相关联并且可以在那里解决?
  2. 如果第一项失败,是否可能不会抛出CURL NSS错误,而是获得响应? CURLOPT_FAILONERROR选项无效。
  3. CURL是用NSS构建的:

    curl 7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
    Protocols: tftp ftp telnet dict ldap ldaps http file https ftps scp sftp
    Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz
    

    更新

    第二项可以关闭,因为这个错误很奇怪:curl_error返回错误,但curl_exec同时返回有效响应。

1 个答案:

答案 0 :(得分:0)

尝试提供证书的绝对路径并添加“./”前缀。例如“./path-to-your-cert”