From: "plaisthos (Code Review)" Date: Tue, 31 Mar 2026 16:24:11 +0000 References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <70e28daf56d1fcb316441e97fce373c520a03cd8-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="WC40ZAsGVuQ="; charset=UTF-8 Subject: [Openvpn-devel] [S] 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: , Cc: openvpn-devel --WC40ZAsGVuQ= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable plaisthos has uploaded this change for review. ( http://gerrit.openvpn.net/= c/openvpn/+/1595?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 --- M src/openvpn/ssl_openssl.c 1 file changed, 47 insertions(+), 0 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/95/1595/1 diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c index c8dd55a..4650b85 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,52 @@ 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."); + } + + 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); + + 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 (ret =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!"); + } + X509_VERIFY_PARAM_free(vpm); +} +#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: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I6c2eda0e5bbb3a70b404f821e25ded81f0f5ddd5 Gerrit-Change-Number: 1595 Gerrit-PatchSet: 1 Gerrit-Owner: plaisthos Gerrit-CC: openvpn-devel --WC40ZAsGVuQ= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

plaisthos has upl= oaded this change for review.

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, 47 insertions(+), 0 delet= ions(-)

git pull ssh://gerrit.openvpn.net:29418/=
openvpn refs/changes/95/1595/1
diff --git a/src/openvpn/ssl_openssl=
.c b/src/openvpn/ssl_openssl.c
index c8dd55a..4650b85 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,52 @@
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.");
+ }
+=
+ 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, c= ert, &error);
+
+ if (error =3D=3D = X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD)
+ {
+ msg(D_TLS_DEBUG_MED, "Failed to read certificate notB= efore field.");
= + }
+ if (error= =3D=3D X509_V_ERR_CERT_NOT_YET_VALID)
+ {
+ msg(M_WARN, "WARNING: Your certificate is not yet valid!&= quot;);
+ }=
+ if (ret =3D=3D X509_V_= ERR_ERROR_IN_CERT_NOT_AFTER_FIELD)
+ {
= + msg(D_TLS_DEBUG_MED, "Failed to read certificate notAfter fie= ld.");
+ }

+ if (error =3D=3D X= 509_V_ERR_CERT_HAS_EXPIRED)
+ {
+ = msg(M_WARN, "WARNING: Your certificate has expired!");+ }
+ X509_VERIFY_PARAM_free(vpm);+}
+#endif

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

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

=
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6c2eda0e5bbb3a70b404f821e25= ded81f0f5ddd5
Gerrit-Change-Number: 1595
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --WC40ZAsGVuQ=--