From a0d1298c4d8de0f3c7543eb8130a9773bbc4b62c Mon Sep 17 00:00:00 2001
From: Reuben Roessler <reuben.roessler@canonical.com>
Date: Thu, 20 Aug 2026 14:38:47 +1000
Subject: [PATCH] d/p/80-fix-openssl4-ftbfs.patch: Fix FTBFS with OpenSSL 4.0
 by replacing ASN1_STRING_data function with ASN1_STRING_get0_data (Closes:
 #1144897)

---
 debian/patches/80-fix-openssl4-ftbfs.patch | 34 ++++++++++++++++++++++
 debian/patches/series                      |  1 +
 2 files changed, 35 insertions(+)
 create mode 100644 debian/patches/80-fix-openssl4-ftbfs.patch

diff --git a/debian/patches/80-fix-openssl4-ftbfs.patch b/debian/patches/80-fix-openssl4-ftbfs.patch
new file mode 100644
index 0000000..0338cb9
--- /dev/null
+++ b/debian/patches/80-fix-openssl4-ftbfs.patch
@@ -0,0 +1,34 @@
+Description: Fix FTBFS with OpenSSL 4.0
+ Since OpenSSL 1.1.1 some accessor functions for the
+ ASN1_STRING type were deprecated and renamed. From
+ OpenSSL 4.0, any of these deprecated functions were
+ removed and needed to be changed to their renamed
+ counterparts.
+ .
+ This patch replaces all instances of ASN1_STRING_data
+ with the ASN1_STRING_get0_data function.
+Author: Reuben Roessler <reuben.roessler@canonical.com>
+Forwarded: https://github.com/zmanda/amanda/pull/292
+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1144897
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/ecflow/+bug/2154891
+Last-Update: 2026-08-20
+--- a/common-src/ssl-security.c
++++ b/common-src/ssl-security.c
+@@ -556,7 +556,7 @@
+     if (loc != -1) {
+ 	X509_NAME_ENTRY *x509_entry = X509_NAME_get_entry(x509_name, loc);
+ 	ASN1_STRING *asn1_string = X509_NAME_ENTRY_get_data(x509_entry);
+-	cert_hostname = (char *)ASN1_STRING_data(asn1_string);
++	cert_hostname = (char *)ASN1_STRING_get0_data(asn1_string);
+ 	auth_debug(1, "common_name: %s\n", cert_hostname);
+ 
+ 	if (ssl_check_certificate_host &&
+@@ -800,7 +800,7 @@
+ 	    if (loc != -1) {
+ 		X509_NAME_ENTRY *x509_entry = X509_NAME_get_entry(x509_name, loc);
+ 		ASN1_STRING *asn1_string = X509_NAME_ENTRY_get_data(x509_entry);
+-		char *cert_hostname =  (char *)ASN1_STRING_data(asn1_string);
++		char *cert_hostname =  (char *)ASN1_STRING_get0_data(asn1_string);
+ 		auth_debug(1, "common_name: %s\n", cert_hostname);
+ 
+ 		if (check_name_give_sockaddr((char*)cert_hostname,
diff --git a/debian/patches/series b/debian/patches/series
index f549f9d..6cfa2f9 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -39,3 +39,4 @@ fix-amserverconfig-template-path
 ######################################################################
 # Patch for gcc 14
 64-amanda-c99
+80-fix-openssl4-ftbfs.patch
-- 
2.53.0

