41a6c3
diff --git a/modules/ssl/ssl_engine_init.c b/modules/ssl/ssl_engine_init.c
41a6c3
index 0275452..8efdcd7 100644
41a6c3
--- a/modules/ssl/ssl_engine_init.c
41a6c3
+++ b/modules/ssl/ssl_engine_init.c
41a6c3
@@ -1144,11 +1144,16 @@ static void ssl_init_server_certs(server_rec *s,
41a6c3
                      OBJ_nid2sn(nid), vhost_id, mctx->pks->cert_files[0]);
41a6c3
     }
41a6c3
     /*
41a6c3
-     * ...otherwise, configure NIST P-256 (required to enable ECDHE)
41a6c3
+     * ...otherwise, enable auto curve selection (OpenSSL 1.0.2 and later)
41a6c3
+     * or configure NIST P-256 (required to enable ECDHE for earlier versions)
41a6c3
      */
41a6c3
     else {
41a6c3
+#if defined(SSL_CTX_set_ecdh_auto)
41a6c3
+        SSL_CTX_set_ecdh_auto(mctx->ssl_ctx, 1);
41a6c3
+#else
41a6c3
         SSL_CTX_set_tmp_ecdh(mctx->ssl_ctx,
41a6c3
                              EC_KEY_new_by_curve_name(NID_X9_62_prime256v1));
41a6c3
+#endif
41a6c3
     }
41a6c3
 #endif
41a6c3
 }