From: "plaisthos (Code Review)" Date: Thu, 2 Apr 2026 12:13:04 +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="h4Ca5on0uz4="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Use ASN1_BIT_STRING_get_bit to check for netscape certificate usage List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: openvpn-devel --h4Ca5on0uz4= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. Hello flichtenheld, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1587?usp=3Demail to look at the new patch set (#6). The following approvals got outdated and were removed: Code-Review-1 by flichtenheld Change subject: Use ASN1_BIT_STRING_get_bit to check for netscape certifica= te usage ...................................................................... Use ASN1_BIT_STRING_get_bit to check for netscape certificate usage The ASN_BIT_STRING object has become opaque in OpenSSL 4.0. So instead of accessing the internal, we have to use a method now to check these attributes. The bit counting in ASN.1 and of this method is a bit strange and it will count bits from the left instead of the right, so the previous mask of 0x80 for clients is now 0 and 0x40 for server is now 1. Change-Id: I77500d435f212a4bf42ee8cfca07d0285fe694f2 Signed-off-by: Arne Schwabe --- M src/openvpn/ssl_verify_openssl.c 1 file changed, 23 insertions(+), 13 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/87/1587/6 diff --git a/src/openvpn/ssl_verify_openssl.c b/src/openvpn/ssl_verify_open= ssl.c index 08946cd..c70022f 100644 --- a/src/openvpn/ssl_verify_openssl.c +++ b/src/openvpn/ssl_verify_openssl.c @@ -609,22 +609,27 @@ if (usage =3D=3D NS_CERT_CHECK_CLIENT) { /* - * Unfortunately, X509_check_purpose() does some weird thing that + * Unfortunately, X509_check_purpose() before OpenSSL 4.0 does som= e weird thing that * prevent it to take a const argument */ result_t result =3D X509_check_purpose(peer_cert, X509_PURPOSE_SSL_CLIENT, 0) ? SU= CCESS : FAILURE; - /* - * old versions of OpenSSL allow us to make the less strict check = we used to - * do. If this less strict check pass, warn user that this might n= ot be the - * case when its distribution will update to OpenSSL 1.1 + * Note that we did not check for netscape certificate type here b= ut + * instead a general SSL/TLS client purpose. These nscert attribut= es + * might stop being accepted by TLS libraries in the future. + * Currently, OpenSSL 4.0 and aws-lc 1.9.0 still consider nscert c= lient + * as acceptable. + * + * So in case that this check failed, we now check if this is caus= ed + * by the check above no longer recognising nscert attributes. */ if (result =3D=3D FAILURE) { ASN1_BIT_STRING *ns; ns =3D X509_get_ext_d2i(peer_cert, NID_netscape_cert_type, NUL= L, NULL); - result =3D (ns && ASN1_STRING_length(ns) > 0 && (ASN1_STRING_g= et0_data(ns)[0] & NS_SSL_CLIENT)) ? SUCCESS : FAILURE; + // bit 0 is to check if certificate is the client certificate + result =3D ASN1_BIT_STRING_get_bit(ns, 0) ? SUCCESS : FAILURE; if (result =3D=3D SUCCESS) { msg(M_WARN, "X509: Certificate is a client certificate yet= it's purpose " @@ -637,22 +642,27 @@ if (usage =3D=3D NS_CERT_CHECK_SERVER) { /* - * Unfortunately, X509_check_purpose() does some weird thing that + * Unfortunately, X509_check_purpose() before OpenSSL 4.0 does som= e weird thing that * prevent it to take a const argument */ result_t result =3D X509_check_purpose(peer_cert, X509_PURPOSE_SSL_SERVER, 0) ? SU= CCESS : FAILURE; /* - * old versions of OpenSSL allow us to make the less strict check = we used to - * do. If this less strict check pass, warn user that this might n= ot be the - * case when its distribution will update to OpenSSL 1.1 + * Note that we did not check for netscape certificate type here b= ut + * instead a general SSL/TLS server purpose. These nscert attribut= es + * might stop being accepted by TLS libraries in the future. + * Currently, OpenSSL 4.0 and aws-lc 1.9.0 still consider nscert s= erver + * as acceptable. + * + * So in case that this check failed, we now check if this is caus= ed + * by the check above no longer recognising nscert attributes. */ if (result =3D=3D FAILURE) { - ASN1_BIT_STRING *ns; - ns =3D X509_get_ext_d2i(peer_cert, NID_netscape_cert_type, NUL= L, NULL); - result =3D (ns && ASN1_STRING_length(ns) > 0 && (ASN1_STRING_g= et0_data(ns)[0] & NS_SSL_SERVER)) ? SUCCESS : FAILURE; + ASN1_BIT_STRING *ns =3D X509_get_ext_d2i(peer_cert, NID_netsca= pe_cert_type, NULL, NULL); + // Server bit is 1 for ASN1_BIT_STRING_get_bit + result =3D ASN1_BIT_STRING_get_bit(ns, 1) ? SUCCESS : FAILURE; if (result =3D=3D SUCCESS) { msg(M_WARN, "X509: Certificate is a server certificate yet= it's purpose " -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1587?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: I77500d435f212a4bf42ee8cfca07d0285fe694f2 Gerrit-Change-Number: 1587 Gerrit-PatchSet: 6 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld --h4Ca5on0uz4= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: flichtenheld, plaisthos.

plaisthos uploaded patch set #6 to this change.

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

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

Use ASN1_BIT_STRING_get_bit =
to check for netscape certificate usage

The ASN_BIT_STRING object ha= s become opaque in OpenSSL 4.0. So instead
of accessing the internal, we= have to use a method now to check these
attributes.

The bit coun= ting in ASN.1 and of this method is a bit strange and
it will count bits= from the left instead of the right, so the previous
mask of 0x80 for cl= ients is now 0 and 0x40 for server is now 1.

Change-Id: I77500d435f2= 12a4bf42ee8cfca07d0285fe694f2
Signed-off-by: Arne Schwabe <arne@...1711...= 27...>
---
M src/openvpn/ssl_verify_openssl.c
1 file changed, 2= 3 insertions(+), 13 deletions(-)

git pull ssh:=
//gerrit.openvpn.net:29418/openvpn refs/changes/87/1587/6
diff --=
git a/src/openvpn/ssl_verify_openssl.c b/src/openvpn/ssl_verify_openssl.c
index 08946cd..c70022f 100644
--- a/src/open= vpn/ssl_verify_openssl.c
+++ b/src/openvpn/ssl_verify_opens= sl.c
@@ -609,22 +609,27 @@
if (usage = =3D=3D NS_CERT_CHECK_CLIENT)
{
= /*
- * Unfort= unately, X509_check_purpose() does some weird thing that
+ * Unfortunately, X509_check_p= urpose() before OpenSSL 4.0 does some weird thing that
= * prevent it to take a const argument
*/
result_t result =3D
X50= 9_check_purpose(peer_cert, X509_PURPOSE_SSL_CLIENT, 0) ? SUCCESS : FAILURE;=
-
= /*
- * old= versions of OpenSSL allow us to make the less strict check we used to
- * do. If this les= s strict check pass, warn user that this might not be the
- * case when its distribution w= ill update to OpenSSL 1.1
+ * Note that we did not check for netscape certificate type h= ere but
+ * i= nstead a general SSL/TLS client purpose. These nscert attributes
= + * might stop being ac= cepted by TLS libraries in the future.
+ * Currently, OpenSSL 4.0 and aws-lc 1.9.0 still= consider nscert client
+ * as acceptable.
+ *
= + * So in case that this check failed, we now check if this is caus= ed
+ * by the= check above no longer recognising nscert attributes.
= */
if (result =3D=3D FAILURE)
{

ASN1_BIT_STRING *ns;
ns =3D X509_get_ext_d2i(peer_cert, NID_netscape_cert_type, = NULL, NULL);

- = result =3D (ns && ASN1_STRING_length(ns) > 0 && (ASN1= _STRING_get0_data(ns)[0] & NS_SSL_CLIENT)) ? SUCCESS : FAILURE;<= br>+ // bit 0 is to = check if certificate is the client certificate
+ result =3D ASN1_BIT_STRING_get_bit(n= s, 0) ? SUCCESS : FAILURE;
if (result =3D=3D S= UCCESS)
{
msg= (M_WARN, "X509: Certificate is a client certificate yet it's purpo= se "
@@ -637,22 +642,27 @@
if (us= age =3D=3D NS_CERT_CHECK_SERVER)
{
= /*
- * Un= fortunately, X509_check_purpose() does some weird thing that
+ * Unfortunately, X509_che= ck_purpose() before OpenSSL 4.0 does some weird thing that

= * prevent it to take a const argument
*= /
result_t result =3D
= X509_check_purpose(peer_cert, X509_PURPOSE_SSL_SERVER, 0) ? SUCCESS : FAIL= URE;

/*
- * old versions of OpenSSL allow us to= make the less strict check we used to
- * do. If this less strict check pass, warn user t= hat this might not be the
- * case when its distribution will update to OpenSSL 1.1=
+ * Note that we di= d not check for netscape certificate type here but
+ * instead a general SSL/TLS server = purpose. These nscert attributes
+ * might stop being accepted by TLS libraries in the f= uture.
+ * Cu= rrently, OpenSSL 4.0 and aws-lc 1.9.0 still consider nscert server+ * as acceptable.
+ *
<= span style=3D"color: hsl(120, 100%, 40%);">+ * So in case that this= check failed, we now check if this is caused

+ * by the check above no longer recognisi= ng nscert attributes.
*/
= if (result =3D=3D FAILURE)
{
- ASN1_BIT_STRING *ns;- ns =3D X509_get_ext= _d2i(peer_cert, NID_netscape_cert_type, NULL, NULL);
- result =3D (ns && ASN1_= STRING_length(ns) > 0 && (ASN1_STRING_get0_data(ns)[0] & NS_= SSL_SERVER)) ? SUCCESS : FAILURE;
+ ASN1_BIT_STRING *ns =3D X509_get_ext_d2i(peer_cer= t, NID_netscape_cert_type, NULL, NULL);
+ // Server bit is 1 for ASN1_BIT_STRING_get_= bit
+ resu= lt =3D ASN1_BIT_STRING_get_bit(ns, 1) ? SUCCESS : FAILURE;
= if (result =3D=3D SUCCESS)
{
msg(M_WARN, "X509: Certificate is a serve= r certificate yet it's purpose "

=

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

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I77500d435f212a4bf42ee8cfca0= 7d0285fe694f2
Gerrit-Change-Number: 1587
Gerrit-PatchSet: 6
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: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
= --h4Ca5on0uz4=--