sp->ssl = SSL_new (sp->ctx);
SSL_set_fd (sp->ssl, h->iofile);
}
- res = SSL_connect (sp->ssl);
+ res = SSL_connect(sp->ssl);
+#if HAVE_OPENSSL_SSL_H
if (res <= 0)
{
int err = SSL_get_error(sp->ssl, res);
h->cerrno = CSERRORSSL;
return -1;
}
+#else
+ TRC(fprintf(stderr, "SSL_connect res=%d last_error=%d\n",
+ res, sp->ssl->last_error));
+ if (res == 0 && sp->ssl->last_error == GNUTLS_E_AGAIN)
+ {
+ h->io_pending = CS_WANT_READ;
+ return 1;
+ }
+ else if (res <= 0)
+ {
+ h->cerrno = CSERRORSSL;
+ return -1;
+ }
+#endif
}
#endif
h->event = CS_DATA;
tcpip_state *state = (tcpip_state *)h->cprivate;
if (state->ctx)
{
- int res = SSL_accept (state->ssl);
+ int res;
TRC(fprintf(stderr, "SSL_accept\n"));
+ res = SSL_accept (state->ssl);
+#if HAVE_OPENSSL_SSL_H
if (res <= 0)
{
int err = SSL_get_error(state->ssl, res);
cs_close (h);
return 0;
}
+#else
+ TRC(fprintf(stderr, "SSL_accept res=%d last_error=%d\n",
+ res, state->ssl->last_error));
+ if (res == 0 && state->ssl->last_error == GNUTLS_E_AGAIN)
+ {
+ h->io_pending = CS_WANT_READ;
+ return h;
+ }
+ else if (res <= 0) /* assume real error */
+ {
+ cs_close(h);
+ return 0;
+ }
+#endif
}
#endif
}
SSL *ssl = (SSL *) cs_get_ssl(cs);
if (ssl)
{
- X509 *server_cert = SSL_get_peer_certificate (ssl);
#if HAVE_OPENSSL_SSL_H
+ X509 *server_cert = SSL_get_peer_certificate (ssl);
if (server_cert)
{
BIO *bio = BIO_new(BIO_s_mem());