Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libcurl gnutls_handshake() failed: A TLS warning alert has been received

Tags:

c

ssl

libcurl

I am essentially trying to do the following:

http://curl.haxx.se/libcurl/c/https.html

I have my apache server set up with mod_ssl and a server cert. I added the line:

curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);

and also tried:

curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);

but I keep getting the error: gnutls_handshake() failed: A TLS warning alert has been received.

Does anyone know who to fix this or get around it?

like image 601
wonbyte Avatar asked Jan 19 '23 21:01

wonbyte


2 Answers

Realizing that the question is fairly old and one answer was already accepted, here is an alternative answer that worked perfectly for me and may be useful for folks coming here from search:

  • Replace libcurl-gnutls with libcurl-openssl alternative.

I noticed that the certificate error was only generated with programs using libcurl and not with browsers so I assumed that something about GNUTLS was at fault here and not the certificates.

Here is what worked for me (Ubuntu 12.04 LTS):

$ sudo apt-get remove libcurl4-gnutls-dev
$ sudo apt-get install libcurl4-openssl-dev 

All programs that were relying on libcurl started working fine immediately after I replaced the libraries (I also recompiled the programs just in case).

Note: this solution will only help you if you get a warning with GNUTLS but not with, say, browsers. That is, I am assuming the certificate chain is actually set up correctly.

like image 80
akhmed Avatar answered Jan 22 '23 12:01

akhmed


I attempted the above solution and that did not work for me. In python, I tried the following option which effectively forces SSLv3 and disables TLS.

c.setopt(pycurl.SSLVERSION, pycurl.SSLVERSION_SSLv3)

in PHP it should be able to be accomplished by setting the CURLOPT_SSLVERSION option to 3.

like image 44
tufelkinder Avatar answered Jan 22 '23 11:01

tufelkinder