Currently there is no reason to rant about python3 and ssl, as there is no real wrapper yet.
But, for python2.x we got m2crypto.
Using m2crypto with nonblocking sockets?
PyObject *ssl_connect(SSL *ssl) {
PyObject *obj = NULL;
int r, err;
Py_BEGIN_ALLOW_THREADS
r = SSL_connect(ssl);
Py_END_ALLOW_THREADS
switch (SSL_get_error(ssl, r)) {
case SSL_ERROR_NONE:
case SSL_ERROR_ZERO_RETURN:
obj = PyInt_FromLong((long)1);
break;
case SSL_ERROR_WANT_WRITE:
case SSL_ERROR_WANT_READ:
obj = PyInt_FromLong((long)0);
break;
case SSL_ERROR_SSL:
PyErr_SetString(_ssl_err, ERR_reason_error_string(ERR_get_error()));
obj = NULL;
break;
case SSL_ERROR_SYSCALL:
err = ERR_get_error();
if (err)
PyErr_SetString(_ssl_err, ERR_reason_error_string(err));
else if (r == 0)
PyErr_SetString(_ssl_err, "unexpected eof");
else if (r == -1)
PyErr_SetFromErrno(_ssl_err);
obj = NULL;
break;
}
return obj;
}
_ssl.i
Once this is done, and returns 1, you need a magic oracle to get an idea what happend, and what needs to be done, same problem for nonblocking reads and writes.
Unfortunately m2crypto does not ship with such magic oracle.