I'm currently working on an ArchLinux 4.7.2-1 x86_64 Server and try to write an application using libcurl for HTTP(S) requests. So for example I do something like this:
#include <curl/curl.h>
int main(void)
{
CURL* curl_handle = curl_easy_init();
curl_easy_setopt(curl_handle, CURLOPT_URL, "https://google.at");
curl_easy_setopt(curl_handle, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS | CURLPROTO_HTTP);
curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_easy_perform(curl_handle);
curl_easy_cleanup(curl_handle);
return 0;
}
I know that I would have to specify a WriteFunction to receive the response body but that isn't the question. As long as the response does not contain a redirect URL everything is fine. But when it comes to (HTTPS) redirects some breaks inside of OpenSSL.
* Rebuilt URL to: https://google.at/
* Trying 172.217.21.99...
* Connected to google.at (172.217.21.99) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: none
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use http/1.1
* Server certificate:
* subject: C=US; ST=California; L=Mountain View; O=Google Inc; CN=*.google.at
* start date: Aug 24 10:10:00 2016 GMT
* expire date: Nov 16 10:10:00 2016 GMT
* subjectAltName: host "google.at" matched cert's "google.at"
* issuer: C=US; O=Google Inc; CN=Google Internet Authority G2
* SSL certificate verify ok.
> GET / HTTP/1.1
Host: google.at
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
Accept: */*
< HTTP/1.1 301 Moved Permanently
< Location: https://www.google.at/
< Content-Type: text/html; charset=UTF-8
< Date: Fri, 02 Sep 2016 11:42:53 GMT
< Expires: Sun, 02 Oct 2016 11:42:53 GMT
< Cache-Control: public, max-age=2592000
< Server: gws
< Content-Length: 219
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< Alt-Svc: quic=":443"; ma=2592000; v="36,35,34,33,32,31,30"
<
* Ignoring the response-body
* Connection #0 to host google.at left intact
* Issue another request to this URL: 'https://www.google.at/'
* Trying 216.58.201.163...
* Connected to www.google.at (216.58.201.163) port 443 (#1)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
ElectricFence Exiting: mprotect() failed: Cannot allocate memory
Btw. I am using
Does anyone know what causes this problem and has a solution? If I forgot important information feel free to ask.
In order to get rid of this error I followed the instructions provided at Understanding the output of electric fence and gdb:
echo 128000 > /proc/sys/vm/max_map_count
Increasing the memory map areas to 128000
did it.