Thanks...

I actually have all the socket stuff working fine with regular sockets
(under both NT and linux), it was just the OpenSSL additions to make my code
handle SSL that I was interested in.

Fortunately, I've now got that working too :)

Thanks again for your help.  Now... if only I could figure out how to
determine if the server has closed the SSL connection on me... more reading
I guess.

----- Original Message -----
From: Geoff Thorpe <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, October 29, 1999 4:27 AM
Subject: Re: Docs for someone new to OpenSSL


Hi Mike,

On Thu, 28 Oct 1999, Mike Benna wrote:

> Any suggested reading?

The C files in openssl/apps can be handy if you're patient. And for the
network stuff, try "Unix Network Programming - Volume 1" by W. Richard
Stevens. As for Win32 conversions, most of the standard socket functions
exist albeit with the odd difference here and there, and the error
handling is quite different. The easiest way is to open VC++, open the
source, position the cursor over the function name ("send, recv, connect",
or whatever) and hit F1 ... then it's up to you and MSDN to work out where
to head next.

> More specifically, I'm trying to use open SSL to replace these 6
> client calls so that I can fetch pages using https.
>
>     sock = socket(PF_INET, SOCK_STREAM, 0);
>     sockerr = fcntl(sock, F_SETFL, O_NONBLOCK); // enable non-blocking
mode.
>     sockerr = connect(sock, (LPSOCKADDR)&connection_address,
sizeof(connection_address));
>     bytes_sent = send(sock, request_str, strlen(request_str), 0);
>     received = recv(sock, download_buffer+bytes_in_buffer,
BUFFER_SIZE-bytes_in_buffer, 0);
>     closesocket(sock);

You can't assume to send everything in one go and receive everything in
one go when using non-blocking IO. In fact that code should fail for more
than one reason - (a) the connect is non-blocking so your first "send"
should fail because the connect isn't complete. Even then, the first
"recv" should also fail as the server wouldn't have received the request
yet from the send.

I assume you've psuedo-coded this or the non-blocking call was not being
called ... either way - you can stick a socket (file descriptor) into a
BIO and that can link up to an SSL BIO using a "client_method" and ...
well, openssl/apps/s_client.c should show you how this is done (it uses
some functions defined in the other s_*.c files too so you're better to
take some time to work your way through it all slowly).

> I only need this to work under Linux, but if the Win32 version is
> trivial, that would be an added bonus.

Shouldn't be too difficult.

> Any pointers to suggested reading would be appreciated.

s_client and s_server are your friend [;-)

Cheers,
Geoff


----------------------------------------------------------------------
Geoff Thorpe                                    Email: [EMAIL PROTECTED]
Cryptographic Software Engineer, C2Net Europe    http://www.int.c2.net
----------------------------------------------------------------------
May I just take this opportunity to say that of all the people I have
EVER emailed, you are definitely one of them.

______________________________________________________________________
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]

Reply via email to