cURL / Mailing Lists / curl-library / Single Mail


bad request with SSL; libcurl 7.19.4 SSL enabled / Win32

From: Thomas Reinhardt <>
Date: Tue, 14 Apr 2009 11:19:20 +0200

I have the following problem. Our very restrictive new proxy criticizes the
POST-URL in line 20 from the transscript below, written by the debug_function.
It looks like the URL is broken. The URL should contain also protocol and

wrong: POST /servlets/tstOnline HTTP/1.1

should be: POST HTTP/1.1

If I disable SSL, the POST-URL is correct and the proxy is happy.

without SSL: POST HTTP/1.1

But I have to use SSL. Is there any workaround?

best regards

Thomas Reinhardt

xmls_init("", "", "xxx.xx.192.5:8845", "\\fs5\fs1\templates", "\\fs5\fs1\tmp", 5)
send_xml("", "\\fs5\fs1\tmp\_login.xml", "xxx.xx.192.5:8845")
About to connect() to port 443 (#0)
  Trying connected
Connected to ( port 443 (#0)
SSL re-using session ID
SSLv3, TLS handshake, Client hello (1):
SSLv3, TLS handshake, Server hello (2):
SSLv3, TLS change cipher, Client hello (1):
SSLv3, TLS handshake, Finished (20):
SSLv3, TLS change cipher, Client hello (1):
SSLv3, TLS handshake, Finished (20):
SSL connection using DES-CBC-SHA
Server certificate:
         SSL certificate verify result: self signed certificate (18), continuing anyway.
POST /servlets/tstOnline HTTP/1.1
Accept: */*
Content-Type: text/xml
User-Agent: xmlsptst.dll
Content-Length: 142

<?xml version="1.0" encoding="ISO-8859-1"?>
HTTP 1.0, assume close after body
HTTP/1.0 400 Bad Request
Date: Tue, 14 Apr 2009 08:07:33 GMT
Content-Type: text/html

<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="" lang="en-US" xml:lang="en-US">
<title>Bad Request</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="SHORTCUT ICON" href="/genua-wwwrelay-internal/genua.ico" />
<link rel="stylesheet" type="text/css" href="/genua-wwwrelay-internal/gg.css" />
  <div id="header">
    <div id="version">GeNUGate WWW Proxy</div>
  <div id="page">
<h1>Bad Request</h1>Bad url in proxy request
<address>Generated by your GeNUGate-Proxy (wwwrelay) on</address>

Closing connection #0
SSLv3, TLS alert, Client hello (1):

The shortened source:

// ssl_test
#include "stdafx.h"

#include <direct.h>

#include <stdio.h>
#include <stdlib.h>

#include <sys/stat.h>

#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>

static CURL *curl;

static int initialized=0;
static int max_connects=3;
static int xmlctimeout=0;


size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream) {
        int written = fwrite(ptr, size, nmemb, (FILE *)stream);
        return written;


int debug_function(CURL *curl, curl_infotype cit, char *dt, size_t len, void *vp) {

        char *temp;
        FILE *debugfile;
        char debugfilename[255];
        temp = (char *) malloc(len+1);

        strncpy(temp, dt, len);

        strcpy(debugfilename, "_debug.txt");

        if((debugfile = fopen(debugfilename,"ab")) != NULL) {
                if(cit < 5){
                        fprintf(debugfile, "%s", temp);


        return 0;


void wait(int sec) {

        time_t t = time(NULL);
        char function_call[_MAX_PATH];
        sprintf(function_call, "wait(%d)\n", sec);
        debug_function(curl, CURLINFO_TEXT, function_call, strlen(function_call), NULL);

        while((time(NULL) - t) <= (time_t) sec);


int send_xml(char *url, char *filename, char *proxy) {

        struct stat stat_p;
        struct curl_slist *headers=NULL;

        int res;
        int trials=0, i=0;

        FILE *datafile;
        char *xml;
        char datafilename[255];

        long length;

        char function_call[_MAX_PATH];
        sprintf(function_call, "send_xml(\"%s\", \"%s\", \"%s\")\n", url, filename, proxy);
        debug_function(curl, CURLINFO_TEXT, function_call, strlen(function_call), NULL);

        strcpy(datafilename, "_temp.xml");

        if ( -1 == stat (filename, &stat_p)) {
        length = stat_p.st_size;

        if (length == 0) {

        xml = (char *) malloc(length+1);

        if((datafile = fopen(filename,"rb")) != NULL) {
                fread(xml, sizeof(BYTE), length, datafile);


        res = curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
        res = curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, debug_function);
        res = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);

        datafile = fopen(datafilename,"w");

        res = curl_easy_setopt(curl, CURLOPT_WRITEDATA, datafile);

        if(curl) {
                if(url[4] == 's') {
                        res = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);
                        res = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
                } else {
                        res = curl_easy_setopt(curl, CURLOPT_PROXY, proxy);

                res = curl_easy_setopt(curl, CURLOPT_URL, url);
                res = curl_easy_setopt(curl, CURLOPT_POST, TRUE);
                res = curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) length);
                res = curl_easy_setopt(curl, CURLOPT_POSTFIELDS, xml);

                headers = curl_slist_append(headers, "Content-Type: text/xml");
                res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

                res = -1;
                while ((res != 0) && (++trials <= max_connects))
                        res = curl_easy_perform(curl);

                        if(res != 0) {



        return 0;


int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpCmdLine,
                     int nCmdShow )
        if((curl = curl_easy_init()) != NULL) {
// send_xml("", "_login.xml", "");
                send_xml("", "_login.xml", "");
        return 0;

Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen:
Received on 2009-04-14