diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c
index fbd38f3..295fd47 100644
--- a/src/openvpn/crypto_openssl.c
+++ b/src/openvpn/crypto_openssl.c
@@ -61,9 +61,14 @@
 #error Windows build with OPENSSL_NO_EC: disabling EC key is not supported.
 #endif
 
+#if HAVE_OPENSSL_ENGINE && OPENSSL_VERSION_NUMBER >= 0x30000000L
+/* mute ossl3 deprecation warnings */
 #ifdef _MSC_VER
-/* mute ossl3 deprecation warnings treated as errors in msvc */
 #pragma warning(disable: 4996)
+#else
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
 #endif
 
 /*
@@ -1454,4 +1459,12 @@
     return false;
 }
 #endif /* if LIBRESSL_VERSION_NUMBER */
+
+#if HAVE_OPENSSL_ENGINE && OPENSSL_VERSION_NUMBER >= 0x30000000L
+/* mute ossl3 deprecation warnings */
+#ifndef _MSC_VER
+#pragma GCC diagnostic pop
+#endif
+#endif
+
 #endif /* ENABLE_CRYPTO_OPENSSL */
