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="pcxBOTNxpeg="; 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 --pcxBOTNxpeg= 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/+/1587?usp=3Demail to look at the new patch set (#4). 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 ANS.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, 15 insertions(+), 12 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/87/1587/4 diff --git a/src/openvpn/ssl_verify_openssl.c b/src/openvpn/ssl_verify_open= ssl.c index 08946cd..a15640d 100644 --- a/src/openvpn/ssl_verify_openssl.c +++ b/src/openvpn/ssl_verify_openssl.c @@ -609,22 +609,24 @@ 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 do not check for netscape certificate type here bu= t rather + * check for a gneral SSL/TLS client purpose. We do not know how l= ong nscert + * attributes are accepted by TLS library in the future. Currently= OpenSSL 4.0 + * and aws-lc 1.9.0 still consider nscert client as acceptable. */ 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 +639,23 @@ 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 do not check for netscape certificate type here bu= t rather + * check for a gneral SSL/TLS server purpose. We do not know how l= ong nscert + * attributes are accepted by TLS library in the future. Currently= OpenSSL 4.0 + * and aws-lc 1.9.0 still consider nscert server as acceptable. */ 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: 4 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: flichtenheld --pcxBOTNxpeg= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: flichtenheld.

plaisthos uploaded patch set #4 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 ANS.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, 1= 5 insertions(+), 12 deletions(-)

git pull ssh:=
//gerrit.openvpn.net:29418/openvpn refs/changes/87/1587/4
diff --=
git a/src/openvpn/ssl_verify_openssl.c b/src/openvpn/ssl_verify_openssl.c
index 08946cd..a15640d 100644
--- a/src/open= vpn/ssl_verify_openssl.c
+++ b/src/openvpn/ssl_verify_opens= sl.c
@@ -609,22 +609,24 @@
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 mak= e the less strict check we used to
- * do. If this less strict check pass, warn user that = this might not be the
-= * case when its distribution will update to OpenSSL 1.1
= + * Note that we do not= check for netscape certificate type here but rather
+ * check for a gneral SSL/TLS cli= ent purpose. We do not know how long nscert
+ * attributes are accepted by TLS library i= n the future. Currently OpenSSL 4.0
+ * and aws-lc 1.9.0 still consider nscert client as= acceptable.
*/
if (resu= lt =3D=3D FAILURE)
{
= ASN1_BIT_STRING *ns;
ns =3D X509_get_ext_d2i(p= eer_cert, NID_netscape_cert_type, NULL, NULL);
- result =3D (ns && ASN1_STRING_= length(ns) > 0 && (ASN1_STRING_get0_data(ns)[0] & NS_SSL_CLI= ENT)) ? SUCCESS : FAILURE;
+ // bit 0 is to check if certificate is the client certif= icate
+ re= sult =3D ASN1_BIT_STRING_get_bit(ns, 0) ? SUCCESS : FAILURE;
if (result =3D=3D SUCCESS)

{
msg(M_WARN, "X509: Certificate is a cli= ent certificate yet it's purpose "
@@ -637,22 +639= ,23 @@
if (usage =3D=3D NS_CERT_CHECK_SERVER) {
/*
- * Unfortunately, X509_check_purpose() does so= me weird thing that
+= * Unfortunately, X509_check_purpose() before OpenSSL 4.0 does some= weird thing that
* prevent it to take a const ar= gument
*/
result_t resul= t =3D
X509_check_purpose(peer_cert, X509_PURPO= SE_SSL_SERVER, 0) ? SUCCESS : FAILURE;

= /*
- * o= ld versions of OpenSSL allow us to make the less strict check we used to
- * do. If this l= ess strict check pass, warn user that this might not be the
- * case when its distribution= will update to OpenSSL 1.1

+ * Note that we do not check for netscape certificate type = here but rather
+ = * check for a gneral SSL/TLS server purpose. We do not know how long n= scert
+ * att= ributes are accepted by TLS library in the future. Currently OpenSSL 4.0
+ * and aws-lc = 1.9.0 still consider nscert server as acceptable.
= */
if (result =3D=3D FAILURE)
= {
- AS= N1_BIT_STRING *ns;
- = ns =3D X509_get_ext_d2i(peer_cert, NID_netscape_cert_type, NULL, N= ULL);
- resu= lt =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_cert, NID_netscape_cert_type, NULL, NULL);
=
+ // Server bit = is 1 for ASN1_BIT_STRING_get_bit
+ result =3D ASN1_BIT_STRING_get_bit(ns, 1) ? SUCCES= S : FAILURE;
if (result =3D=3D SUCCESS)=
{
msg(M_WARN, "= ;X509: Certificate is a server 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: 4
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...>
= --pcxBOTNxpeg=--