Re: Please help: SSL_read() hang after read http 100 continue header

2002-11-13 Thread marcus.carey
Lin

No I am not an OpenSSL developer.  However I have built several server and
client applications using OpenSSL.

The the following code works with IE 5.0 and the simple client program I
sent you.

 BIO_puts(io,HTTP/1.1 100 Continue\r\n);
 BIO_puts(io,Server: Microsoft-IIS/5.0\r\n);
 BIO_puts(io,Date: Wed, 30 Oct 2002 06:34:5 6 GMT\r\n\r\n);
 /* the extra 0d 0a after the Date header is needed to tells the browser it
has reached the end of the block before reading the 200 reponse code */
/* Without the \r\n the server sends an invalid response to the browser */

 BIO_puts(io,HTTP/1.1 200 OK\r\n);
 BIO_puts(io,Server: Microsoft-IIS/5.0\r\n);
 BIO_puts(io,Date: Wed,30 Oct 20 02 06:35:07 GMT\r\n);
 BIO_puts(io,Content-Length: 1863\r\n);
 BIO_puts(io,Content-Type: text/html\r\n);
 BIO_puts(io,Expires: Wed, 30 Oct 2002 06:35: 07 GMT\r\n);
 BIO_puts(io,Cache-control: private\r\n);
 BIO_puts(io,\r\n);

 BIO_puts(io,html\r\n);
 BIO_puts(io,head\r\n);
 BIO_puts(io,titleBIO Openssl Test Server/title\r\n);
 BIO_puts(io,/head\r\n);
 BIO_puts(io,body\r\n);
 BIO_puts(io,centerfont face=VerdanaBIO OpenSSL Test
Server/font/center\r\n);
 BIO_puts(io,/body\r\n);
 BIO_puts(io,/html\r\n);




Browser output:
html
head
titleBIO Openssl Test Server/title
/head
body
centerfont face=VerdanaBIO OpenSSL Test Server/font/center
/body
/html

Simple client output

Wrote 17 chars
Handshake completed successfully!
Read 411 chars:
HTTP/1.1 100 Continue
Server: OpenSSL/1.0
Date: Wed, 30 Oct 2002 06:34:5 6 GMT

HTTP/1.1 200 OK
Date: Wed,30 Oct 20 02 06:35:07 GMT
Content-Length: 1863
Content-Type: text/html
Expires: Wed, 30 Oct 2002 06:35: 07 GMT
Cache-control: private

html
head
titleBIO Openssl Test Server/title
/head
body
centerfont face=VerdanaBIO OpenSSL Test Server/font/center
/body
/html


I am running this code on Windows 2000 Server with VC++ 6.0.  Send me your
client or server code so that I can look at it.


- Original Message -
From: Lutz Jaenicke [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Wednesday, November 13, 2002 1:13 PM
Subject: Re: Please help: SSL_read() hang after read http 100 continue
header


 On Wed, Nov 13, 2002 at 09:53:34AM -0800, Lin Ma wrote:
  I have a client program using Openssl to send request to and receive
  response from a web server. SSL_read hangs if the web server sends the
  following headers.
 
  The following is the header dump without SSL. I think the problem is the
  separator 0d 0a 0d 0a between the two block of headers.

 No. The SSL layer does not care about the data transferred, whether it
 is line oriented or not.

 ...
  You can see, it is like
  HTTP/1.1 100 Continue
  Server: Microsoft-IIS/5.0
  Date: Wed,  30 Oct 2002 06:34:56 GMT
  0d 0a 0d 0a
  HTTP/1.1 200 OK
  Server: Microsoft-IIS/5.0
  Date: Wed,  30 Oct 2002 06:34:56 GMT
  Content-Length: 1863
  .
 
  There is separator 0d 0a 0d 0a between the two block of headers. My
program
  just stuck in the separator and couldn't get the following HTTP/1.1 200
OK
  ...
 
  If I change it to non-blocking, SSL_read() doesn't hang any more, but it
  keep getting SSL_ERROR_WANT_READ error, if I keeping SSL_read, it keep
  getting SSL_ERROR_WANT_READ and doesn't return valid data.

 This means, that no data has been received or at least not enough data
 to complete the TLS record. SSL_read() is waiting for (more) data.

 Use ssldump to analyze the traffic.
 What platform are you working on? Windows or UNIX? Can you try your
 program on another platform?
 Microsoft IIS is not know to be free of errors, but it seems to work
 good enough that I don't think the problem is caused by the server side.

 Best regards,
 Lutz
 --
 Lutz Jaenicke [EMAIL PROTECTED]
 http://www.aet.TU-Cottbus.DE/personen/jaenicke/
 BTU Cottbus, Allgemeine Elektrotechnik
 Universitaetsplatz 3-4, D-03044 Cottbus
 __
 OpenSSL Project http://www.openssl.org
 User Support Mailing List[EMAIL PROTECTED]
 Automated List Manager   [EMAIL PROTECTED]

__
OpenSSL Project http://www.openssl.org
User Support Mailing List[EMAIL PROTECTED]
Automated List Manager   [EMAIL PROTECTED]



Re: Please help: SSL_read() hang after read http 100 continue header

2002-11-13 Thread Lutz Jaenicke
On Wed, Nov 13, 2002 at 09:53:34AM -0800, Lin Ma wrote:
 I have a client program using Openssl to send request to and receive
 response from a web server. SSL_read hangs if the web server sends the
 following headers.
  
 The following is the header dump without SSL. I think the problem is the
 separator 0d 0a 0d 0a between the two block of headers.

No. The SSL layer does not care about the data transferred, whether it
is line oriented or not.

...
 You can see, it is like
 HTTP/1.1 100 Continue
 Server: Microsoft-IIS/5.0
 Date: Wed,  30 Oct 2002 06:34:56 GMT
 0d 0a 0d 0a
 HTTP/1.1 200 OK
 Server: Microsoft-IIS/5.0
 Date: Wed,  30 Oct 2002 06:34:56 GMT
 Content-Length: 1863
 .
  
 There is separator 0d 0a 0d 0a between the two block of headers. My program
 just stuck in the separator and couldn't get the following HTTP/1.1 200 OK
 ... 
  
 If I change it to non-blocking, SSL_read() doesn't hang any more, but it
 keep getting SSL_ERROR_WANT_READ error, if I keeping SSL_read, it keep
 getting SSL_ERROR_WANT_READ and doesn't return valid data.

This means, that no data has been received or at least not enough data
to complete the TLS record. SSL_read() is waiting for (more) data.

Use ssldump to analyze the traffic.
What platform are you working on? Windows or UNIX? Can you try your
program on another platform?
Microsoft IIS is not know to be free of errors, but it seems to work
good enough that I don't think the problem is caused by the server side.

Best regards,
Lutz
-- 
Lutz Jaenicke [EMAIL PROTECTED]
http://www.aet.TU-Cottbus.DE/personen/jaenicke/
BTU Cottbus, Allgemeine Elektrotechnik
Universitaetsplatz 3-4, D-03044 Cottbus
__
OpenSSL Project http://www.openssl.org
User Support Mailing List[EMAIL PROTECTED]
Automated List Manager   [EMAIL PROTECTED]