diff --git a/main/iostream.c b/main/iostream.c
index d060b6d6d445cda68d6ce6968ad4ce8b4b15b9fe..7727983423bcb29d2f465f0232bb2b84b018092d 100644
--- a/main/iostream.c
+++ b/main/iostream.c
@@ -553,7 +553,7 @@ int ast_iostream_close(struct ast_iostream *stream)
 					ERR_error_string(sslerr, err), ssl_error_to_string(sslerr, res));
 			}
 
-#if !defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x10100000L)
+#if !(defined(LIBRESSL_VERSION_NUMBER) && (LIBRESSL_VERSION_NUMBER < 0x2070000L)) && (OPENSSL_VERSION_NUMBER >= 0x10100000L)
 			if (!SSL_is_server(stream->ssl)) {
 #else
 			if (!stream->ssl->server) {