git: 29c7d4a9f835 - main - security/xmlsec1: fix build when using libressl

From: Hiroki Sato <hrs_at_FreeBSD.org>
Date: Fri, 06 May 2022 20:25:03 UTC
The branch main has been updated by hrs:

URL: https://cgit.FreeBSD.org/ports/commit/?id=29c7d4a9f83548fee47722fcc60ad33bbdfa9f87

commit 29c7d4a9f83548fee47722fcc60ad33bbdfa9f87
Author:     Hiroki Sato <hrs@FreeBSD.org>
AuthorDate: 2022-05-06 20:23:19 +0000
Commit:     Hiroki Sato <hrs@FreeBSD.org>
CommitDate: 2022-05-06 20:24:48 +0000

    security/xmlsec1: fix build when using libressl
    
    PR:     263826
---
 security/xmlsec1/files/patch-src-openssl-app.c | 70 ++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/security/xmlsec1/files/patch-src-openssl-app.c b/security/xmlsec1/files/patch-src-openssl-app.c
new file mode 100644
index 000000000000..c723cad64dad
--- /dev/null
+++ b/security/xmlsec1/files/patch-src-openssl-app.c
@@ -0,0 +1,70 @@
+--- src/openssl/app.c.orig	2022-05-03 23:36:17.000000000 +0900
++++ src/openssl/app.c	2022-05-07 05:18:46.065103000 +0900
+@@ -43,6 +43,29 @@
+ 
+ #include "openssl_compat.h"
+ 
++#if defined(XMLSEC_OPENSSL_API_110) && defined(LIBRESSL_VERSION_NUMBER)
++static UI_METHOD *
++ui_null_create(void)
++{
++	return (UI_create_method("OpenSSL NULL UI"));
++}
++static void
++ui_null_destroy(UI_METHOD *ui)
++{
++	UI_destroy_method(ui);
++}
++#else
++static const UI_METHOD *
++ui_null_create(void)
++{
++	return (UI_null());
++}
++static void
++ui_null_destroy(const UI_METHOD *ui)
++{
++}
++#endif
++
+ static int      xmlSecOpenSSLAppLoadRANDFile            (const char *filename);
+ static int      xmlSecOpenSSLAppSaveRANDFile            (const char *filename);
+ static int      xmlSecOpenSSLDefaultPasswordCallback    (char *buf,
+@@ -415,6 +438,11 @@
+     EVP_PKEY* pKey = NULL;
+     int engineInit = 0;
+     int ret;
++#if defined(XMLSEC_OPENSSL_API_110) && defined(LIBRESSL_VERSION_NUMBER)
++    UI_METHOD *ui_null = ui_null_create();
++#else
++    const UI_METHOD *ui_null = ui_null_create();
++#endif
+ 
+ #ifndef OPENSSL_NO_ENGINE
+     xmlSecAssert2(engineName != NULL, NULL);
+@@ -437,7 +465,7 @@
+         }
+     }
+ 
+-    if(ENGINE_ctrl_cmd(engine, "SET_USER_INTERFACE", 0, (void *)UI_null(), 0, 1) < 0) {
++    if(ENGINE_ctrl_cmd(engine, "SET_USER_INTERFACE", 0, (void *)ui_null, 0, 1) < 0) {
+         xmlSecOpenSSLError("ENGINE_ctrl_cmd_string(SET_USER_INTERFACE)", NULL);
+         goto done;
+     }
+@@ -453,7 +481,7 @@
+ 
+     /* load private key */
+     pKey = ENGINE_load_private_key(engine, engineKeyId,
+-                                   (UI_METHOD *)UI_null(),
++                                   (UI_METHOD *)ui_null,
+                                    NULL);
+     if(pKey == NULL) {
+         xmlSecOpenSSLError("ENGINE_load_private_key", NULL);
+@@ -484,6 +512,7 @@
+     data = NULL;
+ 
+ done:
++    ui_null_destroy(ui_null);
+     /* cleanup */
+     if(pKey != NULL) {
+         EVP_PKEY_free(pKey);