diff --git a/libi2pd/Crypto.h b/libi2pd/Crypto.h
--- a/libi2pd/Crypto.h
+++ b/libi2pd/Crypto.h
@@ -29,12 +29,13 @@
 #include "CPU.h"
 
 // recognize openssl version and features
-#if ((OPENSSL_VERSION_NUMBER < 0x010100000) || defined(LIBRESSL_VERSION_NUMBER)) // 1.0.2 and below or LibreSSL
+#if ((OPENSSL_VERSION_NUMBER < 0x010100000) || (LIBRESSL_VERSION_NUMBER < 0x3050000fL)) // 1.0.2 and below or LibreSSL < 3.5.0
 #   define LEGACY_OPENSSL 1
 #   define X509_getm_notBefore X509_get_notBefore
 #   define X509_getm_notAfter X509_get_notAfter
 #else
 #   define LEGACY_OPENSSL 0
+# if !defined LIBRESSL_VERSION_NUMBER
 #   if (OPENSSL_VERSION_NUMBER >= 0x010101000) // 1.1.1
 #       define OPENSSL_HKDF 1
 #       define OPENSSL_EDDSA 1
@@ -46,6 +47,7 @@
 #   if !defined OPENSSL_NO_CHACHA && !defined OPENSSL_NO_POLY1305 // some builds might not include them
 #       define OPENSSL_AEAD_CHACHA20_POLY1305 1
 #   endif
+# endif
 #endif
 
 namespace i2p
