I've seen a similar problems that related to the GetLastError() value being trampled on.  In my case, it was caused by the SSL error stack code calling my thread_id function which called the GNU pthread's pthread_self function which called some Win32 function (GetTlsValue?) which is documented as trashing the last error value.  The "error" that the error-stack was reporting was WSAWOULDBLOCK, which is expected in such a situation.  SSL_sock_should_retry would have realised this had the last error value not have been reset.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Pascal Janse van Vuuren
Sent: Wednesday, 14 November 2001 2:23 PM
To: [EMAIL PROTECTED]
Subject: SSL_connect / SSL_accept

Hi,
 
Thanks to everyone who helped out with the previous problem. I've since gone ahead and started fixing all the inconsistencies I created. However, I'm now having a more programmatic type problem.
 
Using Win2K, I'm having problems with the actual SSL_accept and SSL_connect. At the point where this happens, the sockets are non-blocking. However, my first SSL_connect fails with error code 5 (SSL_ERROR_SYSCALL) A call to SSL_get_error() returns 0, which according to the docco means EOF / other protocol violation. On my implementation, this means the current object (Containing everything - including the underlying socket) is destroyed. If I retry the connection attempt however, it works fine and as expected.
 
Any suggestions / thoughts on what could be causing this ?
 
--[Some setup]--------------------------------
 SSL_library_init();
 SSL_load_error_strings(); 
 
    m_pMethod = SSLv23_method();
    m_pContext = SSL_CTX_new(m_pMethod);
 
// I don't specify a method, but when tracing through the code, I see that the method is automatically determined...
// Might be wrong here ?
// I'm going to try it with an explicit set, and see if that makes a difference...
 
--[Server side]----------------------------------
 
/* Some source */
 int sslReturn = SSL_accept(m_pSSL);
 int nError   = 0;
 
 if(sslReturn < 0)
 {
  nError = SSL_get_error(m_pSSL,sslReturn);
  switch(nError)
  {
 
--[Client side]--------------------
 sslReturn = SSL_connect(m_pSSL);
 
 if(sslReturn > 0)
 {
    // Do some stuff
 }
 else
 {
// sslReturn == -1
 
  nError = SSL_get_error(m_pSSL,sslReturn);
 
// At this point nError == 5
 
  int nExtraInfo = ERR_get_error();
 
// nExtraInfo contains 0 - I haven't done any processing here though
 }
 
__________________________________________
 
Pascal
Qbik New Zealand
 
"meddle not in the affairs of dragons,  for ye are
 crunchy and taste good with tomato sauce"

Reply via email to