Index: ext/openssl/xp_ssl.c
--- ext/openssl/xp_ssl.c.orig
+++ ext/openssl/xp_ssl.c
@@ -76,7 +76,7 @@
 #define HAVE_TLS12 1
 #endif
 
-#ifndef OPENSSL_NO_TLS1_3
+#ifndef OPENSSL_NO_TLS1_3 && !defined(LIBRESSL_VERSION_NUMBER)
 #define HAVE_TLS13 1
 #endif
 
@@ -89,9 +89,7 @@
 #define HAVE_TLS_ALPN 1
 #endif
 
-#ifndef LIBRESSL_VERSION_NUMBER
 #define HAVE_SEC_LEVEL 1
-#endif
 
 #if OPENSSL_VERSION_NUMBER < 0x40000000L && !defined(OPENSSL_NO_SSL3)
 #define HAVE_SSL3 1
@@ -631,7 +629,7 @@ static bool php_openssl_matches_common_name(php_stream
 	}
 	name_asn1 = X509_NAME_ENTRY_get_data(name_entry);
 	cert_name_len = ASN1_STRING_get_length(name_asn1);
-	cert_name = (unsigned char *) OPENSSL_strndup((const char *) ASN1_STRING_get0_data(name_asn1), cert_name_len);
+	cert_name = (unsigned char *) strndup((const char *) ASN1_STRING_get0_data(name_asn1), cert_name_len);
 	if (cert_name == NULL) {
 		php_stream_warn(stream, NetworkRecvFailed, "Unable to locate peer certificate CN");
 		return false;
@@ -647,7 +645,7 @@ static bool php_openssl_matches_common_name(php_stream
 			cert_name_len, (const char *)cert_name, subject_name);
 	}
 
-	OPENSSL_free(cert_name);
+	free(cert_name);
 
 	return is_match;
 }
