Nelson B wrote:
Rob Crittenden wrote:
In an SSL client I want to force the SSL handshake to take place instead of passively waiting for it to happen during the first write.

Right after I connect to the server I'm currently doing this:

   SSL_ResetHandshake(ssl, /* asServer */ PR_FALSE);
   do {
     SSL_ForceHandshake(ssl);
     PR_Recv (ssl, handshake, 1, PR_MSG_PEEK, 100);
     err = PR_GetError();
   } while (err != PR_END_OF_FILE_ERROR && handshake_done == 0);


This code may also run into bug 273861.
https://bugzilla.mozilla.org/show_bug.cgi?id=273861
Be sure there's no unread data on the sslsocket before calling ForceHandshake.


Yup, the poll did the trick. I used PR_Recv because I knew it would force the handshake without doing any unexpected I/O (on the off-chance there actually WAS something to read. Didn't even consider using PR_Poll, it is working nicely.

One change I've made from tstclnt is using PR_ConnectContinue() instead of PR_GetConnectStatus() which is deprecated.

The socket is already connected by the time I start doing any NSS calls. I'm getting a connected socket and pushing SSL on top of that (rather than doing PR_Connect() myself).

Do you know if this comment from tstclnt is still true?

/* Must milliPause between PR_Poll and PR_GetConnectStatus,
 * Or else winsock gets mighty confused.
 * Sleep(0);

Do I really need a millisecond pause between the poll and PR_ConnectContinue()?

thanks

rob
_______________________________________________
dev-tech-crypto mailing list
dev-tech-crypto@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-crypto

Reply via email to