Hello!

I'm not a very advanced programmer so I hope you
won't lough at me. I have a small problem and I
don't know why it's happening so I'm asking.

I'm trying to make a client for some web-site
(basically a program that should make it easier
for the user to use the features on that web-site
than by actually using the web-interface).

After making some bad experiences with WinInet (eg
automatically sending cookies that I don't wanted
to send in the first place...) I tried with OpenSSL
and with a little experimenting I was able to
compile 0.96c and link at get no errors or crashes.

Basically I just want to communicate with the server
as a client (no client certificates, just authentication
with password, then I get a session ID as cookie).

Now everything seems to work (I can send and receive
over the SSL connection) but I do get some strange
3 byte junk data sometime when SSL_read-ing and I
don't know why.

As said I'm no guru and I have very little experience
but as everything seems to be working fine except
this 3 byte junk I'd like to know how to prevent that
too.

Here's some of my code:

...
SSL_library_init();
SSL_load_error_strings();
SSLeay_add_all_algorithms ();
SSLeay_add_ssl_algorithms ();
...
SSL_METHOD *meth = NULL;
SSL_CTX *ssl_ctx = NULL;
meth = SSLv2_client_method();
ssl_ctx = SSL_CTX_new(meth);
SSL * ssl = NULL;
ssl = SSL_new(ssl_ctx);
...
sock = socket(AF_INET, SOCK_STREAM, 0);
...
if(connect(sock,(struct sockaddr *) &sock_name, sizeof (sock_name)))
...
SSL_set_fd(ssl, sock);
SSL_connect(ssl);
...
SSL_write(ssl, strsend, strsend.GetLength()); //sending HTTP POST
...
char buf[1000];
while(nret = SSL_read(ssl, buf, 999))
{
        buf[nret] = 0;
        m_out += buf;
        UpdateData(FALSE); //output HTML to a edit box so
                                //i can see what's coming
}
...

now the problem is that I get some 3 byte junk in between
like eg this:

...
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html

d48
<HTML>
<HEAD>
...

where is that "d48" coming from???

btw this is not between those 2 999 byte reads but
in the middle of the first one.
other occurences of these strange 3 bytes (it's
not always d48, each occurence has a different
value but if I run the program again on the same
https-page I do get the same 3 byte values in the
same places) seem to happen more frequently when
only a few bytes are read (eg I saw that a few
reads only received 4 or 5 bytes and there ware
often these strange 3 bytes too).

communication with the server is in SSLv2 btw

Can anyone help to eliminate this bug?

Did I make some silly mistake maybe that's not even
related to OpenSSL?

thanks for any input on this!

Johann Müller
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to