Set up a BIO socket and use the BIO_gets() function. Below is a modified example that I got from Eric Rescorla to solve this problem.
#define BUFSIZE 1024 BIO *bio_err; int Http_Read(void) { BIO *io; BIO *sbio; BIO *ssl_bio; SSL *ssl; SSL_CTX *ctx; int i; int c; int r; int Socket; char buffer[BUFSIZE]; char *tok; /* Setup you Socket */ /* Initialize SSL context */ sbio = BIO_new_socket(Socket,BIO_NO_CLOSE); ssl = SSL_new(ctx); SSL_set_bio(ssl,sbio,sbio); io = BIO_new(BIO_f_buffer()); ssl_bio = BIO_new(BIO_f_ssl()); BIO_set_ssl(ssl_bio,ssl,BIO_CLOSE); BIO_push(io,ssl_bio); c = i?-1:0; while(1) { r = BIO_gets(io,buf,BUFSIZE-1); switch(SSL_get_error(ssl,r)) { case SSL_ERROR_NONE: break; case SSL_ERROR_ZERO_RETURN: return(-1); default: berr_exit("SSL read problem"); } // Look for the blank line that signals // the end of the HTTP headers if(!strcmp(buf,"\r\n") || !strcmp(buf,"\n")) break; if(!(tok = strtok(buf,": "))) err_exit("Parse error"); if(!stricmp(tok,"Content-Length")) { tok = strtok(0,": "); c = atoi(tok); } if(c == -1) err_exit("Server HTTP message without content-length"); while(c) { int tr = c > BUFSIZE?BUFSIZE:c; r = BIO_read(io,buf,tr); buf[r] = '\0'; switch(SSL_get_error(ssl,r)) { case SSL_ERROR_NONE: c -= tr; break; default: berr_exit("SSL read problem"); } } if((r = BIO_flush(io)) < 0) err_exit("Error flushing BIO"); SSL_set_shutdown(ssl,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); if(io != NULL) { BIO_free_all(io); } } int berr_exit(char *string) { BIO_printf(bio_err,"%s\n",string); ERR_print_errors(bio_err); return(0); } int err_exit(char *string) { fprintf(stderr,"%s\n",string); return(0); } ----- Original Message ----- From: "Asad Ali" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, November 01, 2002 4:19 PM Subject: SSL_read() fails for IE 6.0 ? > > Hi, > > I am new to OpenSSL and am running into a strange behavior > in my web server application. The web server uses OpenSSL library > from 0.9.6g distribution. When the web server is accessed via > Netscape 4.76 browser, it works fine. However, the same URL > fails when using IE 6.0.26. The problem happens because the > first call to SSL_read(), after handshake, returns zero bytes. > I am, therefore, unable to read the GET message from IE. > > Have anyone seen this kind of behavior before. I am using > Cygwin on Windows 2000 system. > > thanks, > --- asad > ______________________________________________________________________ > 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]