SSL write error with curl

11.2k views Asked by At

I tried to connect with curl using php-curl and curl in command line but I receive following errors:

PHP Script:

$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

Command Line:

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

couldn't find any explanation of those errors anywhere.

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

There are 1 answers

1
user35201 On

You can see from this link that it has to do with the remote server closing the connection. This could be due to the CA not being trusted or any number of SSL issues. As far as I can tell it is an issue with the remote server, not your curl configuration.