--- src/network.c
+++ src/network.c
@@ -31,6 +31,8 @@
 #  include <openssl/dh.h>
 # endif
 # include <openssl/bn.h>
+# include <openssl/bio.h>
+# include <openssl/pem.h>
 
 # if OPENSSL_VERSION_NUMBER >= 0x0090800fL
 #  ifndef OPENSSL_NO_ECDH
@@ -688,9 +690,8 @@
 #endif
 
 #ifdef USE_OPENSSL
-# ifndef OPENSSL_NO_DH
+#if !defined(OPENSSL_NO_DH) && !defined(OPENSSL_NO_BIO)
 	DH *dh;
-# endif
 	BIO *bio;
 
        /* 1024-bit MODP Group with 160-bit prime order subgroup (RFC5114)
@@ -732,6 +733,7 @@
 		0x85,0x5E,0x6E,0xEB,0x22,0xB3,0xB2,0xE5,
 	};
 #endif
+#endif
 
 	struct nb_map {
 		network_backend_t nb;
@@ -875,7 +877,7 @@
 			}
 		}
 
-#ifndef OPENSSL_NO_DH
+#if !defined(OPENSSL_NO_DH) && !defined(OPENSSL_NO_BIO)
 		/* Support for Diffie-Hellman key exchange */
 		if (!buffer_string_is_empty(s->ssl_dh_file)) {
 			/* DH parameters from file */
