diff --git a/src/compat.h b/src/compat.h index 00d320c..8848f3d 100644 --- a/src/compat.h +++ b/src/compat.h @@ -48,4 +48,10 @@ //------------------------------------------------------------------------------ +#if !defined(LIBRESSL_VERSION_NUMBER) && ((OPENSSL_VERSION_NUMBER & 0xFFFFF000L) == 0x10101000L) +#define LSEC_OPENSSL_1_1_1 +#endif + +//------------------------------------------------------------------------------ + #endif diff --git a/src/ssl.c b/src/ssl.c index 82ed595..2cd213f 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -48,6 +48,11 @@ static int lsec_socket_error() #if defined(WIN32) return WSAGetLastError(); #else +#if defined(LSEC_OPENSSL_1_1_1) + // Bug in OpenSSL 1.1.1 + if (errno == 0) + return LSEC_IO_SSL; +#endif return errno; #endif } @@ -182,10 +187,6 @@ static int ssl_send(void *ctx, const char *data, size_t count, size_t *sent, ssl->error = SSL_ERROR_SSL; return LSEC_IO_SSL; } - /* Return failure when SSL reports syscall error - * but errno is not set to break send operation. */ - if (errno == 0) - return LSEC_IO_SSL; if (err == 0) return IO_CLOSED; return lsec_socket_error();