URL: https://github.com/freeipa/freeipa/pull/1012
Author: abbra
 Title: #1012: csrgen: support openssl 1.0 and 1.1
Action: opened

PR body:
"""
Support both openssl 1.0 and 1.1 APIs where sk_* functions got prefixed
with OPENSSL_ in the latter version.

Since referencing a symbol from a dynamically loaded library generates
exception, use the AttributeError exception to catch it and fall back to
the older method.

Fixes https://pagure.io/freeipa/issue/7110
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/1012/head:pr1012
git checkout pr1012
From 8e44d6182e68c87e919009df5ef153791115b7a4 Mon Sep 17 00:00:00 2001
From: Alexander Bokovoy <aboko...@redhat.com>
Date: Fri, 25 Aug 2017 21:46:12 +0300
Subject: [PATCH] csrgen: support openssl 1.0 and 1.1

Support both openssl 1.0 and 1.1 APIs where sk_* functions got prefixed
with OPENSSL_ in the latter version.

Since referencing a symbol from a dynamically loaded library generates
exception, use the AttributeError exception to catch it and fall back to
the older method.

Fixes https://pagure.io/freeipa/issue/7110
---
 ipaclient/csrgen_ffi.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/ipaclient/csrgen_ffi.py b/ipaclient/csrgen_ffi.py
index c45db5f147..d5b04b88d0 100644
--- a/ipaclient/csrgen_ffi.py
+++ b/ipaclient/csrgen_ffi.py
@@ -34,6 +34,9 @@
 /* openssl/stack.h */
 typedef ... _STACK;
 
+int OPENSSL_sk_num(const _STACK *);
+void *OPENSSL_sk_value(const _STACK *, int);
+
 int sk_num(const _STACK *);
 void *sk_value(const _STACK *, int);
 
@@ -125,8 +128,12 @@
 NCONF_get_string = _libcrypto.NCONF_get_string
 
 # openssl/stack.h
-sk_num = _libcrypto.sk_num
-sk_value = _libcrypto.sk_value
+try:
+    sk_num = _libcrypto.OPENSSL_sk_num
+    sk_value = _libcrypto.OPENSSL_sk_value
+except AttributeError as e:
+    sk_num = _libcrypto.sk_num
+    sk_value = _libcrypto.sk_value
 
 
 def sk_CONF_VALUE_num(sk):
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org

Reply via email to