From: "cron2 (Code Review)" Date: Sat, 18 Apr 2026 18:33:10 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., matthias.andree@...68..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <43680f83a6ddf7f04fbe4b30384e786edec8cb85-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="YaY3em5G7I0="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: mandree , flichtenheld , openvpn-devel --YaY3em5G7I0= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/15= 95?usp=3Demail ) Change subject: OpenSSL 4.0: Use X509_check_certificate_times instead of X5= 09_cmp_time ...................................................................... OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time The X509_cmp_time function is deprecated in OpenSSL 4.0. So we avoid it and use the new API. Change-Id: I6c2eda0e5bbb3a70b404f821e25ded81f0f5ddd5 Signed-off-by: Arne Schwabe Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1595 Message-Id: <20260417164644.17897-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg36= 651.html Signed-off-by: Gert Doering --- M src/openvpn/ssl_openssl.c 1 file changed, 55 insertions(+), 0 deletions(-) diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c index efe5b5b..6130dc3 100644 --- a/src/openvpn/ssl_openssl.c +++ b/src/openvpn/ssl_openssl.c @@ -634,6 +634,7 @@ #endif /* if OPENSSL_VERSION_NUMBER < 0x30000000L */ } +#if OPENSSL_VERSION_NUMBER < 0x40000000L void tls_ctx_check_cert_time(const struct tls_root_ctx *ctx) { @@ -669,6 +670,60 @@ msg(M_WARN, "WARNING: Your certificate has expired!"); } } +#else +void +tls_ctx_check_cert_time(const struct tls_root_ctx *ctx) +{ + const X509 *cert; + ASSERT(ctx); + + cert =3D SSL_CTX_get0_certificate(ctx->ctx); + + if (cert =3D=3D NULL) + { + return; /* Nothing to check if there is no certificate */ + } + + X509_VERIFY_PARAM *vpm =3D X509_VERIFY_PARAM_new(); + + if (vpm =3D=3D NULL) + { + msg(D_TLS_DEBUG_MED, "Failed to initialise certificate verificatio= n parameters."); + return; + } + + X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_USE_CHECK_TIME); + X509_VERIFY_PARAM_set_time(vpm, now); + + int error =3D 0; + int ret =3D X509_check_certificate_times(vpm, cert, &error); + X509_VERIFY_PARAM_free(vpm); + + if (ret =3D=3D 1) + { + return; + } + + switch (error) + { + case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: + msg(D_TLS_DEBUG_MED, "Failed to read certificate notBefore fie= ld."); + break; + + case X509_V_ERR_CERT_NOT_YET_VALID: + msg(M_WARN, "WARNING: Your certificate is not yet valid!"); + break; + + case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: + msg(D_TLS_DEBUG_MED, "Failed to read certificate notAfter fiel= d."); + break; + + case X509_V_ERR_CERT_HAS_EXPIRED: + msg(M_WARN, "WARNING: Your certificate has expired!"); + break; + } +} +#endif void tls_ctx_load_dh_params(struct tls_root_ctx *ctx, const char *dh_file, bool= dh_file_inline) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1595?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: merged Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I6c2eda0e5bbb3a70b404f821e25ded81f0f5ddd5 Gerrit-Change-Number: 1595 Gerrit-PatchSet: 6 Gerrit-Owner: plaisthos Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-CC: mandree Gerrit-CC: openvpn-devel --YaY3em5G7I0= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 sub= mitted this change.

View Change

OpenSSL 4.0: Use X509_check_certificate_times in=
stead of X509_cmp_time

The X509_cmp_time function is deprecated in O= penSSL 4.0. So we avoid it and
use the new API.

Change-Id: I6c2ed= a0e5bbb3a70b404f821e25ded81f0f5ddd5
Signed-off-by: Arne Schwabe <arne= @...1227...>
Acked-by: Gert Doering <gert@...1296...>
Gerrit= URL: https://gerrit.openvpn.net/c/openvpn/+/1595
Message-Id: <202604= 17164644.17897-1-gert@...1296...>
URL: https://www.mail-archive.com/o= penvpn-devel@lists.sourceforge.net/msg36651.html
Signed-off-by: Gert Doe= ring <gert@...1296...>
---
M src/openvpn/ssl_openssl.c
1 fil= e changed, 55 insertions(+), 0 deletions(-)

diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c
index efe5b5b..6130dc3 100644
--- a/src/openvpn/= ssl_openssl.c
+++ b/src/openvpn/ssl_openssl.c
@@ -634,6 +634,7 @@
#endif /* if OPENSSL_VERSION_NUMBER= < 0x30000000L */
}

+#if OPENSSL_VERSION_NUMBER < 0x400= 00000L
void
tls_ctx_check_cert_time(const= struct tls_root_ctx *ctx)
{
@@ -669,6 +67= 0,60 @@
msg(M_WARN, "WARNING: Your certificat= e has expired!");
}
}
= +#else
+void
+tls_ctx_check_cert_time(const struct tls_root_ctx *ctx)

+{
+ const X509 *cert;
+ ASSERT(ctx);
+
+ cert =3D SSL_CTX_get0_certificate(ctx->ctx);+
+ if (cert =3D=3D NULL)
+ {
+ return; /* Nothing to check if there is no cert= ificate */
+ }

+
+ X509_VERIFY_PARAM *vpm =3D X509_VERIF= Y_PARAM_new();
+
+ if (vpm =3D=3D NULL)=
+ {
+ msg(D_TLS_DEBUG_MED, &quo= t;Failed to initialise certificate verification parameters.");
<= br>+ return;
<= span style=3D"color: hsl(120, 100%, 40%);">+ }
+
+ X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_USE_CHECK_TIME)= ;
+ X509_VERIFY_PA= RAM_set_time(vpm, now);
+
+ int error = =3D 0;
+ int ret = =3D X509_check_certificate_times(vpm, cert, &error);
+ X509_VERIFY_PARAM_free(vpm);
+
+ if (ret =3D=3D 1)
+ {
+ return;
+ }
+
+ switch (error= )
+ {
+ case X509_V_ERR_ERROR_IN= _CERT_NOT_BEFORE_FIELD:

+ msg(D_TLS_DEBUG_MED, "Failed to read certificate notBe= fore field.");
+= break;
+<= /span>
+ case X509_V_= ERR_CERT_NOT_YET_VALID:
+ msg(M_WARN, "WARNING: Your certificate is not yet vali= d!");
+ = break;
++ case X509_V_ERR_ERROR= _IN_CERT_NOT_AFTER_FIELD:
+ msg(D_TLS_DEBUG_MED, "Failed to read certificate not= After field.");
= + break;
+=
+ case X509_V= _ERR_CERT_HAS_EXPIRED:
+ bre= ak;
+ }
= +}
+#endif

void
tls_ctx_load_dh_params(struct tls_root_ctx *ctx, const char= *dh_file, bool dh_file_inline)

To view= , visit = change 1595. To unsubscribe, or for help writing mail filters, visit settings.

<= div itemscope itemtype=3D"http://schema.org/EmailMessage">
<= meta itemprop=3D"name" content=3D"View Change"/>
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6c2eda0e5bbb3a70b404f821e25= ded81f0f5ddd5
Gerrit-Change-Number: 1595
Gerrit-PatchSet: 6
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: mandree <matthias.andree@...2908...= .>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --YaY3em5G7I0=--