|
| 1 | +From 17b35e1d635cd70f6d6589031f5f846a369b4748 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Rudi Heitbaum <rudi@heitbaum.com> |
| 3 | +Date: Sun, 22 Mar 2026 00:14:23 +0000 |
| 4 | +Subject: [PATCH 18/18] ssl_verify_openssl: use official ASN1_STRING_ API |
| 5 | +MIME-Version: 1.0 |
| 6 | +Content-Type: text/plain; charset=UTF-8 |
| 7 | +Content-Transfer-Encoding: 8bit |
| 8 | + |
| 9 | +ASN1_STRING are now opaque types in OpenSSL 4.x — the internal data and |
| 10 | +length fields are no longer directly accessible. Use the accessor API |
| 11 | +instead. Accessors have been available since OpenSSL 1.1.0 |
| 12 | + |
| 13 | +The ASN1_STRING_length accessor is already in use, but not consistently |
| 14 | +applied. Standardise on using ASN1_STRING_length and ASN1_STRING_get0_data |
| 15 | +which allows for successful build of OpenSSL 4.x |
| 16 | + |
| 17 | +Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com> |
| 18 | +--- |
| 19 | + src/openvpn/ssl_verify_openssl.c | 8 ++++---- |
| 20 | + 1 file changed, 4 insertions(+), 4 deletions(-) |
| 21 | + |
| 22 | +diff --git a/src/openvpn/ssl_verify_openssl.c b/src/openvpn/ssl_verify_openssl.c |
| 23 | +index 46401cd3..d96879bd 100644 |
| 24 | +--- a/src/openvpn/ssl_verify_openssl.c |
| 25 | ++++ b/src/openvpn/ssl_verify_openssl.c |
| 26 | +@@ -259,7 +259,7 @@ backend_x509_get_username(char *common_name, size_t cn_len, char *x509_username_ |
| 27 | + { |
| 28 | + ASN1_INTEGER *asn1_i = X509_get_serialNumber(peer_cert); |
| 29 | + struct gc_arena gc = gc_new(); |
| 30 | +- char *serial = format_hex_ex(asn1_i->data, asn1_i->length, 0, 1 | FHE_CAPS, NULL, &gc); |
| 31 | ++ char *serial = format_hex_ex(ASN1_STRING_get0_data(asn1_i), ASN1_STRING_length(asn1_i), 0, 1 | FHE_CAPS, NULL, &gc); |
| 32 | + |
| 33 | + if (!serial || cn_len <= strlen(serial) + 2) |
| 34 | + { |
| 35 | +@@ -313,7 +313,7 @@ backend_x509_get_serial_hex(openvpn_x509_cert_t *cert, struct gc_arena *gc) |
| 36 | + { |
| 37 | + const ASN1_INTEGER *asn1_i = X509_get_serialNumber(cert); |
| 38 | + |
| 39 | +- return format_hex_ex(asn1_i->data, asn1_i->length, 0, 1, ":", gc); |
| 40 | ++ return format_hex_ex(ASN1_STRING_get0_data(asn1_i), ASN1_STRING_length(asn1_i), 0, 1, ":", gc); |
| 41 | + } |
| 42 | + |
| 43 | + result_t |
| 44 | +@@ -626,7 +626,7 @@ x509_verify_ns_cert_type(openvpn_x509_cert_t *peer_cert, const int usage) |
| 45 | + { |
| 46 | + ASN1_BIT_STRING *ns; |
| 47 | + ns = X509_get_ext_d2i(peer_cert, NID_netscape_cert_type, NULL, NULL); |
| 48 | +- result = (ns && ns->length > 0 && (ns->data[0] & NS_SSL_CLIENT)) ? SUCCESS : FAILURE; |
| 49 | ++ result = (ns && ASN1_STRING_length(ns) > 0 && (ASN1_STRING_get0_data(ns)[0] & NS_SSL_CLIENT)) ? SUCCESS : FAILURE; |
| 50 | + if (result == SUCCESS) |
| 51 | + { |
| 52 | + msg(M_WARN, "X509: Certificate is a client certificate yet it's purpose " |
| 53 | +@@ -654,7 +654,7 @@ x509_verify_ns_cert_type(openvpn_x509_cert_t *peer_cert, const int usage) |
| 54 | + { |
| 55 | + ASN1_BIT_STRING *ns; |
| 56 | + ns = X509_get_ext_d2i(peer_cert, NID_netscape_cert_type, NULL, NULL); |
| 57 | +- result = (ns && ns->length > 0 && (ns->data[0] & NS_SSL_SERVER)) ? SUCCESS : FAILURE; |
| 58 | ++ result = (ns && ASN1_STRING_length(ns) > 0 && (ASN1_STRING_get0_data(ns)[0] & NS_SSL_SERVER)) ? SUCCESS : FAILURE; |
| 59 | + if (result == SUCCESS) |
| 60 | + { |
| 61 | + msg(M_WARN, "X509: Certificate is a server certificate yet it's purpose " |
| 62 | +-- |
| 63 | +2.53.0 |
| 64 | + |
0 commit comments