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);

If the handshake succeeds the my SSL_HandshakeCallback callback sets handshake_done and I exit the loop. If it fails then sooner or later PR_Recv will set the error to EOF. I don't care if I'm losing the error from the handshake, I do the logging for failures in the SSL_BadCertHook() callback.

My questions are:

1. Do I need the loop or will the PR_Recv, even with such a short timeout, do the trick for me?
2. Is there a better way to do this?

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

Reply via email to