Dne St 12.říj.2016 05:27:04, ppisar napsal(a):
Show quoted text> After upgrading OpenSSL to 1.1.0 build fails like this:
>
Attached patch fixes it.
From ec363dab8b45ae05d5e06bb5a7cbb6caad6a96e3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Fri, 14 Oct 2016 14:48:48 +0200
Subject: [PATCH] Adapt to OpenSSL 1.1.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
OpenSSL 1.1.0 hid structure internals and provides methods for
accessing them. This patch adapts the code so that it can be built
against new and old OpenSSL.
This patch does not address warnings about deprecated symbols in
OpenSSL 1.1.0.
CPAN RT#118345
Signed-off-by: Petr PÃsaÅ <ppisar@redhat.com>
---
PKCS10.xs | 35 ++++++++++++++++++++++++-----------
1 file changed, 24 insertions(+), 11 deletions(-)
diff --git a/PKCS10.xs b/PKCS10.xs
index d00b6ca..af6e2a6 100755
--- a/PKCS10.xs
+++ b/PKCS10.xs
@@ -5,12 +5,21 @@
#include <stdio.h>
#include <stdlib.h>
+#include <openssl/asn1.h>
#include <openssl/pem.h>
#include <openssl/x509v3.h>
#include <openssl/err.h>
#include "ppport.h"
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#define EVP_PKEY_get0_RSA(pkey) ((pkey)->pkey.rsa)
+#define EVP_PKEY_get0_DSA(pkey) ((pkey)->pkey.dsa)
+#ifndef OPENSSL_NO_EC
+#define EVP_PKEY_get0_EC_KEY(pkey) ((pkey)->pkey.ec)
+#endif
+#endif
+
typedef struct
{
X509_REQ* req;
@@ -190,7 +199,7 @@ int add_ext_raw(STACK_OF(X509_REQUEST) *sk, int nid, unsigned char *value, int l
X509_EXTENSION *ex;
ASN1_STRING *asn;
- asn = M_ASN1_OCTET_STRING_new();
+ asn = ASN1_STRING_type_new(V_ASN1_OCTET_STRING);
ASN1_OCTET_STRING_set(asn, value, length);
ex = X509_EXTENSION_create_by_NID(NULL, nid, 0, asn);
@@ -423,6 +432,7 @@ get_pem_pubkey(pkcs10)
PREINIT:
EVP_PKEY *pkey;
BIO *bio;
+ int type;
CODE:
@@ -436,17 +446,18 @@ get_pem_pubkey(pkcs10)
croak("Public Key is unavailable\n");
}
- if (pkey->type == EVP_PKEY_RSA) {
+ type = EVP_PKEY_base_id(pkey);
+ if (type == EVP_PKEY_RSA) {
-# PEM_write_bio_RSAPublicKey(bio, pkey->pkey.rsa);
- PEM_write_bio_RSA_PUBKEY(bio, pkey->pkey.rsa);
+# PEM_write_bio_RSAPublicKey(bio, EVP_PKEY_get0_RSA(pkey));
+ PEM_write_bio_RSA_PUBKEY(bio, EVP_PKEY_get0_RSA(pkey));
- } else if (pkey->type == EVP_PKEY_DSA) {
+ } else if (type == EVP_PKEY_DSA) {
- PEM_write_bio_DSA_PUBKEY(bio, pkey->pkey.dsa);
+ PEM_write_bio_DSA_PUBKEY(bio, EVP_PKEY_get0_DSA(pkey));
#ifndef OPENSSL_NO_EC
- } else if ( pkey->type == EVP_PKEY_EC ) {
- PEM_write_bio_EC_PUBKEY(bio, pkey->pkey.ec);
+ } else if ( type == EVP_PKEY_EC ) {
+ PEM_write_bio_EC_PUBKEY(bio, EVP_PKEY_get0_EC_KEY(pkey));
#endif
} else {
@@ -467,6 +478,7 @@ pubkey_type(pkcs10)
PREINIT:
EVP_PKEY *pkey;
+ int type;
CODE:
RETVAL=NULL;
@@ -475,13 +487,14 @@ pubkey_type(pkcs10)
if(!pkey)
XSRETURN_UNDEF;
- if (pkey->type == EVP_PKEY_DSA) {
+ type = EVP_PKEY_base_id(pkey);
+ if (type == EVP_PKEY_DSA) {
RETVAL="dsa";
- } else if (pkey->type == EVP_PKEY_RSA) {
+ } else if (type == EVP_PKEY_RSA) {
RETVAL="rsa";
#ifndef OPENSSL_NO_EC
- } else if ( pkey->type == EVP_PKEY_EC ) {
+ } else if ( type == EVP_PKEY_EC ) {
RETVAL="ec";
#endif
}
--
2.7.4