From: "cron2 (Code Review)" Date: Sat, 4 Apr 2026 14:00:37 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <05c08a485dd1d3fc33b52c5f8e6d4f9d49439edf-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="/a8qxNVkNM0="; 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: plaisthos , flichtenheld Cc: openvpn-devel --/a8qxNVkNM0= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#7) to the change originally created by= plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1587?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 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 Acked-by: Frank Lichtenheld Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1587 Message-Id: <20260404072336.30014-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg36= 446.html Signed-off-by: Gert Doering --- 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/7 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: 7 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel --/a8qxNVkNM0= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 upl= oaded patch set #7 to the change originally created by plaisthos.<= /p>

Vi= ew Change

The following approvals got outdated and were removed: Code-Review+2 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...>
Acked-by: Frank Lichtenheld <frank@...2641...>
Gerrit= URL: https://gerrit.openvpn.net/c/openvpn/+/1587
Message-Id: <202604= 04072336.30014-1-gert@...1296...>
URL: https://www.mail-archive.com/o= penvpn-devel@lists.sourceforge.net/msg36446.html
Signed-off-by: Gert Doe= ring <gert@...1296...>
---
M src/openvpn/ssl_verify_openssl.c1 file changed, 23 insertions(+), 13 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/87/1587/7<=
/pre>
-   =
      * Unfortunately, X509_check_purpose() does some weird thing that
+ * Unfortunately= , X509_check_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_CLIENT, 0) ? SUCC= ESS : FAILURE;
-=
/*
-= * old versions of OpenSSL allow us to make the less strict check w= e used to
- * d= o. 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 did not check for netscape cert= ificate type here but
+ * instead a general SSL/TLS client purpose. These nscert attribu= tes
+ * might= stop being accepted 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 caused
+ = * by the check above no longer recognising nscert attributes.=
*/
if (result =3D=3D FAILURE)<= /span>
{
ASN1_BIT_STRING *ns= ;
ns =3D X509_get_ext_d2i(peer_cert, NID_netsc= ape_cert_type, NULL, NULL);
- result =3D (ns && ASN1_STRING_length(ns) > 0 &= amp;& (ASN1_STRING_get0_data(ns)[0] & NS_SSL_CLIENT)) ? SUCCESS : F= AILURE;
+ = // bit 0 is to check if certificate is the client certificate
+ result =3D ASN1_BIT_S= TRING_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=
+ * Unfortun= ately, X509_check_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 : FAILURE;


/*- * old versions of Open= SSL allow us to make the less strict check we used to
- * do. If this less strict check pa= ss, warn user that this might not be the
- * case when its distribution will update to Ope= nSSL 1.1
+ * = Note that we did not check for netscape certificate type here but+ * instead a general = SSL/TLS server purpose. These nscert attributes
+ * might stop being accepted by TLS lib= raries in the future.
+ * Currently, OpenSSL 4.0 and aws-lc 1.9.0 still consider nscert = server
+ * as= acceptable.
+ = *
+ * So in= case that this check failed, we now check if this is caused
+ * by the check above no l= onger 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 &= amp;& ASN1_STRING_length(ns) > 0 && (ASN1_STRING_get0_data(n= s)[0] & NS_SSL_SERVER)) ? SUCCESS : FAILURE;
+ ASN1_BIT_STRING *ns =3D X509_get_e= xt_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) ? SUCCESS : FAILURE;
if (result =3D=3D SUCCESS)
= {
msg(M_WARN, "X509: Certifi= cate is a server certificate yet it's purpose "

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

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I77500d435f212a4bf42ee8cfca0= 7d0285fe694f2
Gerrit-Change-Number: 1587
Gerrit-PatchSet: 7
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --/a8qxNVkNM0=--