I used OpenSSL 1.0.2j to develop a desktop email client application with no problems. I copied the code from my desktop to a WinCE 5.0 device .NET CF 2.0. The connection SSL_connect() alway fails with a value of 5 (SSL_ERROR_SYSCALL). A call to CE's GetLastError() on gives me an error 10038 (WSAENOTSOCK Socket operation on nonsocket). Do you have any suggestions? what might be causing this problem?
Thanks in advance
Here's the code:
SSL_library_init()
OPENSSL_add_all_algorithms_noconf()
Dim sslCtx As IntPtr = SSL_CTX_new(SSLv23_client_method())
Dim ssl_socket As IntPtr = SSL_new(sslCtx)
Dim sbioPtr As IntPtr = BIO_new_socket(mySocket.Handle, 0)
SSL_set_bio(ssl_socket, sbioPtr, sbioPtr)
Dim connOK As Integer = SSL_connect(ssl_socket)
If connOK = 1 Then
.....
Else
MsgBox("OpenSSL's SSL_connect() failed")
Dim errcode As Integer = SSL_get_error(ssl_socket, connOK)
MsgBox("SSL Error: " + errcode.ToString)
If errcode = 5 Then
MsgBox("GLE = " + Runtime.InteropServices.Marshal.GetLastWin32Error.ToString)
End If
End If
mySocket.Close()
Else
MsgBox("Socket's connect() failed")
End If
Socket's handle create using CompactFramework on WinCE has always value greater than Int (max value expected on ' BIO_new_socket ')