Просмотр исходного кода

Limit to TLSv1.2 to support ADH connections on LIbreSSL.

TLSv1.3 doesn't support ADH ciphers and LibreSSL does not automatically
fallback like OpenSSL. Both will use a better suite if a certificate is
provided.
Doug Nazar 1 год назад
Родитель
Сommit
c20be0f439
1 измененных файлов с 23 добавлено и 0 удалено
  1. 23 0
      src/nrpe.c

+ 23 - 0
src/nrpe.c

@@ -315,6 +315,29 @@ void init_ssl(void)
 	ssl_set_protocol_version(sslprm.ssl_proto_ver, &ssl_opts);
 	SSL_CTX_set_options(ctx, ssl_opts);
 
+	if (sslprm.allowDH && sslprm.cert_file == 0) {
+		/* If we allow ADH and we don't have a certificate, we need to limit the protocol to below TLSv1.3 as it
+		 * doesn't have support for any ADH cipher suites. OpenSSL will fall back to TLSv1.2 automatically however
+		 * LibreSSL will not.
+		 */
+		int limited = 0;
+
+#if OPENSSL_VERSION_NUMBER >= 0x10100000
+		int max_ver = SSL_CTX_get_max_proto_version(ctx);
+		if (max_ver == 0 || max_ver > TLS1_2_VERSION) {
+			SSL_CTX_set_max_proto_version(ctx, TLS1_2_VERSION);
+			limited = 1;
+		}
+#elif defined(SSL_OP_NO_TLSv1_3)
+		if ((ssl_opts & SSL_OP_NO_TLSv1_3) == 0) {
+			ssl_opts |= SSL_OP_NO_TLSv1_3;
+			limited = 1;
+		}
+#endif
+		if (limited)
+			logit(LOG_WARNING, "WARN: Limiting SSL/TLS version to v1.2 to support ADH");
+	}
+
 	if (!ssl_load_certificates()) {
 		SSL_CTX_free(ctx);
 		exit(STATE_CRITICAL);