From: "plaisthos (Code Review)" Date: Wed, 1 Apr 2026 11:56:52 +0000 In-Reply-To: References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="qVdfXns1sFo="; 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: flichtenheld Cc: openvpn-devel --qVdfXns1sFo= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld. Hello flichtenheld,=20 I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1595?usp=3Demail to look at the new patch set (#3). The following approvals got outdated and were removed: Code-Review-1 by flichtenheld 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 --- M src/openvpn/ssl_openssl.c 1 file changed, 53 insertions(+), 0 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/95/1595/3 diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c index a26663a..fca1d73 100644 --- a/src/openvpn/ssl_openssl.c +++ b/src/openvpn/ssl_openssl.c @@ -615,6 +615,7 @@ #endif /* if OPENSSL_VERSION_NUMBER < 0x30000000L */ } +#if OPENSSL_VERSION_NUMBER < 0x40000000L void tls_ctx_check_cert_time(const struct tls_root_ctx *ctx) { @@ -650,6 +651,58 @@ 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; + } + + if (error =3D=3D X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD) + { + msg(D_TLS_DEBUG_MED, "Failed to read certificate notBefore field."= ); + } + if (error =3D=3D X509_V_ERR_CERT_NOT_YET_VALID) + { + msg(M_WARN, "WARNING: Your certificate is not yet valid!"); + } + if (error =3D=3D X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD) + { + msg(D_TLS_DEBUG_MED, "Failed to read certificate notAfter field."); + } + if (error =3D=3D X509_V_ERR_CERT_HAS_EXPIRED) + { + msg(M_WARN, "WARNING: Your certificate has expired!"); + } +} +#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: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I6c2eda0e5bbb3a70b404f821e25ded81f0f5ddd5 Gerrit-Change-Number: 1595 Gerrit-PatchSet: 3 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: flichtenheld --qVdfXns1sFo= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: flichtenheld.

plaisthos uploaded patch set #3 to this change.

<= a href=3D"http://gerrit.openvpn.net/c/openvpn/+/1595?usp=3Demail">View Chan= ge

The following approvals got outdated and were removed: Code-Review-1 by flichtenheld

OpenSSL 4.0: Use X509_check_=
certificate_times instead of X509_cmp_time

The X509_cmp_time functio= n is deprecated in OpenSSL 4.0. So we avoid it and
use the new API.
<= br>Change-Id: I6c2eda0e5bbb3a70b404f821e25ded81f0f5ddd5
Signed-off-by: A= rne Schwabe <arne@...1227...>
---
M src/openvpn/ssl_openssl.c1 file changed, 53 insertions(+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/95/1595/3<=
/pre>
+#if OPENSSL_VERSION_NUMBER < =
0x40000000L
void
tls_ctx_check_cert_time(= const struct tls_root_ctx *ctx)
{
@@ -650,= 6 +651,58 @@
msg(M_WARN, "WARNING: Your certi= ficate 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 n= o certificate */
+ = }
+
+ X509_VERIFY_PARAM *vpm =3D X509_= VERIFY_PARAM_new();
+=
+ if (vpm =3D=3D = NULL)
+ {+ msg(D_TLS_DEBUG_MED,= "Failed to initialise certificate verification parameters.");
+ return;=
+ }
+
+ X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_USE_CHECK_= TIME);
+ X509_VERI= FY_PARAM_set_time(vpm, now);
+
+ int er= ror =3D 0;
+ int r= et =3D X509_check_certificate_times(vpm, cert, &error);
+ X509_VERIFY_PARAM_free(vpm);
+
+ if (ret =3D=3D 1)
+ {
+ return;
+ }
+
+ if (error = =3D=3D X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD)
+ {
+ msg(D_TLS_DEBUG_MED, "Failed to read certifica= te notBefore field.");
+ }
+ if= (error =3D=3D X509_V_ERR_CERT_NOT_YET_VALID)
+ {
+ msg(M_WARN, "WARNING: Your certificate is not yet = valid!");
+ }=
+ if (error =3D= =3D X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD)
+ {
+ msg(D_TLS_DEBUG_MED, "Failed to read certificate n= otAfter field.");
+ if (err= or =3D=3D X509_V_ERR_CERT_HAS_EXPIRED)
+ {
+ msg(M_WARN, "WARNING: Your certificate has expired!"= );
+ }
<= span style=3D"color: hsl(120, 100%, 40%);">+}

+#endif

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

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

<= meta itemprop=3D"name" content=3D"View Change"/>
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6c2eda0e5bbb3a70b404f821e25= ded81f0f5ddd5
Gerrit-Change-Number: 1595
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
= --qVdfXns1sFo=--