curl-library
bad request with SSL; libcurl 7.19.4 SSL enabled / Win32
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
hostadress.
wrong: POST /servlets/tstOnline HTTP/1.1
should be: POST https://tst-online.tst.de/servlets/tstOnline HTTP/1.1
If I disable SSL, the POST-URL is correct and the proxy is happy.
without SSL: POST http://tst-online.tst.de/servlets/tstOnline HTTP/1.1
But I have to use SSL. Is there any workaround?
best regards
Thomas Reinhardt
-----------snip->8--------------------------------------------------------------
xmls_init("https://tst-online.tst.de/servlets/tstOnline", "https://tst-online.tst.de/servlets/AnfXMLsrv", "xxx.xx.192.5:8845", "\\fs5\fs1\templates", "\\fs5\fs1\tmp", 5)
set_xmlctimeout("5")
initFields()
sendLogin()
create_login_xml()
send_xml("https://tst-online.tst.de/servlets/tstOnline", "\\fs5\fs1\tmp\_login.xml", "xxx.xx.192.5:8845")
About to connect() to tst-online.tst.de port 443 (#0)
Trying 192.168.0.202... connected
Connected to tst-online.tst.de (192.168.0.202) 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
Host: tst-online.tst.de
Accept: */*
Content-Type: text/xml
User-Agent: xmlsptst.dll
Content-Length: 142
<?xml version="1.0" encoding="ISO-8859-1"?>
<TSTIS-LOGIN>
<KENN>xxxxxxxxxx</KENN>
<PASS>xxxxxxxxxx</PASS>
<PASSN/>
<LANG/>
</TSTIS-LOGIN>
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"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<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" />
</head>
<body>
<div>
<div id="header">
<div id="version">GeNUGate WWW Proxy</div>
</div>
<div id="page">
<h1>Bad Request</h1>Bad url in proxy request
<p>
<address>Generated by your GeNUGate-Proxy (wwwrelay) on gg1-dmz1.tst.de</address>
</div>
</div>
</body>
</html>
Closing connection #0
SSLv3, TLS alert, Client hello (1):
parseDoc("c:\fsw\tmp\_temp.xml")
-----------snap-8<--------------------------------------------------------------
The shortened source:
-----------snip->8--------------------------------------------------------------
// 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);
temp[len]='\0';
strcpy(debugfilename, "_debug.txt");
if((debugfile = fopen(debugfilename,"ab")) != NULL) {
if(cit < 5){
fprintf(debugfile, "%s", temp);
}
fclose(debugfile);
}
free(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)) {
return(-1);
}
length = stat_p.st_size;
if (length == 0) {
return(-1);
}
xml = (char *) malloc(length+1);
if((datafile = fopen(filename,"rb")) != NULL) {
fread(xml, sizeof(BYTE), length, datafile);
fclose(datafile);
}
xml[length]='\0';
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) {
wait(xmlctimeout);
}
}
curl_slist_free_all(headers);
}
fclose(datafile);
free(xml);
return 0;
}
//---------------------------------------------------------------------------//
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow )
{
if((curl = curl_easy_init()) != NULL) {
// send_xml("http://tst-online.tst.de/servlets/tstOnline", "_login.xml", "192.168.0.202:8845");
send_xml("https://tst-online.tst.de/servlets/tstOnline", "_login.xml", "");
curl_easy_cleanup(curl);
}
return 0;
}
-----------snap-8<--------------------------------------------------------------
-- Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger01Received on 2009-04-14