From: "plaisthos (Code Review)" Date: Fri, 17 Apr 2026 10:44:40 +0000 In-Reply-To: References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <817d632b2f57fb1eb51c391794964b801b866b34-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="xDttFaRT8hA="; 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 --xDttFaRT8hA= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello flichtenheld, 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 (#5). 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, 55 insertions(+), 0 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/95/1595/5 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: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I6c2eda0e5bbb3a70b404f821e25ded81f0f5ddd5 Gerrit-Change-Number: 1595 Gerrit-PatchSet: 5 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel --xDttFaRT8hA= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

plaisthos uploaded patch set #5 to this change.

View Change

OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time<=
br>
The X509_cmp_time function is deprecated in OpenSSL 4.0. So we avoid= it and
use the new API.

Change-Id: I6c2eda0e5bbb3a70b404f821e25d= ed81f0f5ddd5
Signed-off-by: Arne Schwabe <arne@...1227...>
---<= br>M src/openvpn/ssl_openssl.c
1 file changed, 55 insertions(+), 0 delet= ions(-)

git pull ssh://gerrit.openvpn.net:29418/=
openvpn refs/changes/95/1595/5
diff --git a/src/openvpn/ssl_openssl=
.c b/src/openvpn/ssl_openssl.c
index efe5b5b..6130dc3 10064= 4
--- 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)
+{
+ c= onst X509 *cert;
+ = ASSERT(ctx);
+
+ cert =3D SSL_CTX_get0= _certificate(ctx->ctx);
+
+ if (cert= =3D=3D NULL)
+ {<= /span>
+ return; /* N= othing to check if there is no certificate */
+ }
+
+ X50= 9_VERIFY_PARAM *vpm =3D X509_VERIFY_PARAM_new();
+
+ if (vpm =3D=3D NULL)
+ {
= + msg(D_TLS_DEBUG_MED, "Failed to initialise certificate verifi= cation parameters.");
+ return;
+
= + X509_VERIFY_PARAM_set_flag= s(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);
+ X5= 09_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 field.");
+ break;
+
+ case X509_V_ERR_CERT_NOT_YET_VALID:
+ msg(M_WARN, "WARNIN= G: Your certificate is not yet valid!");
+ break;
+
+ case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD:
+ msg(D_TLS_DEBUG_MED, &= quot;Failed to read certificate notAfter field.");

+ break;
+
+ case X509_V_ERR_CERT_HAS_EXPIRED:
+ msg(M_WARN, "WARNING= : Your certificate has expired!");
+ break;
+ }
+}
+#endif=

void
tls_ctx_load_dh_params(s= truct 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.

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6c2eda0e5bbb3a70b404f821e25= ded81f0f5ddd5
Gerrit-Change-Number: 1595
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --xDttFaRT8hA=--