curl的SSL写入错误

时间:2015-06-17 17:31:14

标签: php curl libcurl

我尝试在命令行中使用php-curl和curl连接curl但是我收到以下错误:

PHP脚本:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://example.com/'); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,2); 
$page = curl_exec($ch);
echo 'Curl error: ' . curl_error($ch);
curl_close($ch);

ERROR:

Curl error: SSL read: errno -5938

命令行:

curl -v https://example.com
* About to connect() to example.com port 443 (#0)
*   Trying IP_ADDRESS... connected
* Connected to example.com (IP_ADDRESS) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* NSS error -12286
* Error in TLS handshake, trying SSLv3...
* SSL write: error -5938
* Failed sending HTTP request
* Connection #0 to host example.com left intact
curl: (55) SSL write: error -5938
* Closing connection #0

无法在任何地方找到任何有关这些错误的解释。

curl --version

curl 7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.16.1 Basic ECC 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



openssl version -a
OpenSSL 1.0.1e-fips 11 Feb 2013
built on: Mon Jun 15 18:29:40 UTC 2015
platform: linux-x86_64
options:  bn(64,64) md2(int) rc4(16x,int) des(idx,cisc,16,int) idea(int) blowfish(idx)
compiler: gcc -fPIC -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DKRB5_MIT -m64 -DL_ENDIAN -DTERMIO -Wall -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wa,--noexecstack -DPURIFY -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM
OPENSSLDIR: "/etc/pki/tls"
engines:  rdrand dynamic

1 个答案:

答案 0 :(得分:2)

您可以从此link看到它与关闭连接的远程服务器有关。这可能是由于CA不受信任或任何数量的SSL问题。据我所知,这是远程服务器的问题,而不是你的卷曲配置。