diff --git a/meta/recipes-extended/sudo/files/0001-lib-iolog-use-accessor-for-ASN1_STRING-length.patch b/meta/recipes-extended/sudo/files/0001-lib-iolog-use-accessor-for-ASN1_STRING-length.patch
new file mode 100644
index 0000000000..5fd98acae0
--- /dev/null
+++ b/meta/recipes-extended/sudo/files/0001-lib-iolog-use-accessor-for-ASN1_STRING-length.patch
@@ -0,0 +1,37 @@
+From f97a34bc7b390f185d544e21b0ef75db1275953e Mon Sep 17 00:00:00 2001
+From: Theo Buehler <tb@openbsd.org>
+Date: Sat, 22 Nov 2025 12:28:50 +0100
+Subject: [PATCH] Use accessor for getting an ASN1_STRING's length
+
+OpenSSL 4 makes ASN1_STRING opaque, so hostcheck.c can no longer read
+->length directly. Use the ASN1_STRING_length() accessor instead.
+
+Upstream-Status: Backport [https://github.com/sudo-project/sudo/commit/f97a34bc7b390f185d544e21b0ef75db1275953e]
+Signed-off-by: Chen Qi <chenqi_hycx@cetc.com.cn>
+---
+ lib/iolog/hostcheck.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/lib/iolog/hostcheck.c b/lib/iolog/hostcheck.c
+--- a/lib/iolog/hostcheck.c
++++ b/lib/iolog/hostcheck.c
+@@ -323,14 +323,14 @@
+ #endif
+ 
+             /* IPV4 address */
+-            if(current_name->d.iPAddress->length == 4) {
++            if (ASN1_STRING_length(current_name->d.iPAddress) == 4) {
+                 if (inet_ntop(AF_INET, san_ip, san_ip_str, INET_ADDRSTRLEN) == NULL) {
+                     result = MalformedCertificate;
+                     break;
+                 }
+ #if defined(HAVE_STRUCT_IN6_ADDR)
+             /* IPV6 address */
+-            } else if (current_name->d.iPAddress->length == 16) {
++            } else if (ASN1_STRING_length(current_name->d.iPAddress) == 16) {
+                 if (inet_ntop(AF_INET6, san_ip, san_ip_str, INET6_ADDRSTRLEN) == NULL) {
+                     result = MalformedCertificate;
+                     break;
+-- 
+2.43.0
+
diff --git a/meta/recipes-extended/sudo/sudo_1.9.17p2.bb b/meta/recipes-extended/sudo/sudo_1.9.17p2.bb
index 489c0db09d..2b01684ee5 100644
--- a/meta/recipes-extended/sudo/sudo_1.9.17p2.bb
+++ b/meta/recipes-extended/sudo/sudo_1.9.17p2.bb
@@ -5,6 +5,7 @@ SRC_URI = "https://www.sudo.ws/dist/sudo-${PV}.tar.gz \
            file://0001-sudo.conf.in-fix-conflict-with-multilib.patch \
 		   file://0001-m4-Backport-ax_prog_cc_for_build.m4-macros.patch \
 		   file://CVE-2026-35535.patch \
+		   file://0001-lib-iolog-use-accessor-for-ASN1_STRING-length.patch \
            "
 
 PAM_SRC_URI = "file://sudo.pam"
