Обновление m2crypto

atratsevskiy
Mike Khiretskiy 9 years ago
parent dbd688cf22
commit fd39624ee4

@ -1 +1 @@
DIST M2Crypto-0.21.1.tar.gz 413563 SHA256 25b94498505c2d800ee465db0cc1aff097b1615adc3ac042a1c85ceca264fc0a SHA512 b261eed84b3bda8a664c065241c2007f6443235a0fbcdd856c5a0b1f015e75662724b72a56e94aeb174414fff5c8dd71dfcb4b18f677f576ab7e30811a8adf9b WHIRLPOOL 88f184452a660cff934371d18e0065974dec3cea052cf78ef0bbecf35ed2ef6d69f8a40016f1b3fbac24fa06697b7e4c5e9e1f6afd20d30ff63fa1c22b69e8d0
DIST M2Crypto-0.22.3.tar.gz 74795 SHA256 6071bfc817d94723e9b458a010d565365104f84aa73f7fe11919871f7562ff72 SHA512 c179d3cf03ced77aed24285ca3f1527d5e05bbfe091a1522bff94a940fd390213fbb9b83d7ccd43ceae49626b427ae8790782cf93ead85be1e063bc4121c62e0 WHIRLPOOL 66a9a6e7c9b195814048a1bcecf6ef71a269bebb9dbda73801c88b3ba27330b555a46d05c53bbd0778f9c1e1bb5f9c6e7e860de443bf16baffc2072ee5996e31

@ -0,0 +1,138 @@
From 803188070e486030cb1d2e53692b39305c742b17 Mon Sep 17 00:00:00 2001
From: Joe Julian <jjulian@io.com>
Date: Tue, 19 May 2015 23:54:08 -0700
Subject: [PATCH] Use swig generated python loader
---
.gitignore | 6 +++++-
M2Crypto/__init__.py | 4 ++--
M2Crypto/m2.py | 4 +---
SWIG/_m2crypto.def | 2 +-
SWIG/_m2crypto.i | 2 +-
setup.py | 25 +++++++++++++++++++++----
6 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/M2Crypto/__init__.py b/M2Crypto/__init__.py
index 647e057..38dbbd5 100644
--- a/M2Crypto/__init__.py
+++ b/M2Crypto/__init__.py
@@ -19,7 +19,7 @@ Copyright 2008-2011 Heikki Toivonen. All rights reserved.
version_info = (0, 22)
version = '.'.join([str(_v) for _v in version_info])
-import __m2crypto
+import m2crypto
import m2
import ASN1
import AuthCookie
@@ -47,4 +47,4 @@ import m2xmlrpclib
import threading
import util
-__m2crypto.lib_init()
+m2crypto.lib_init()
diff --git a/M2Crypto/m2.py b/M2Crypto/m2.py
index e4bb695..516cadb 100644
--- a/M2Crypto/m2.py
+++ b/M2Crypto/m2.py
@@ -25,7 +25,5 @@ Portions created by Open Source Applications Foundation (OSAF) are
Copyright (C) 2004 OSAF. All Rights Reserved.
"""
-from __m2crypto import *
+from m2crypto import *
lib_init()
-
-
diff --git a/SWIG/_m2crypto.def b/SWIG/_m2crypto.def
index 753db2c..3e9d5bc 100644
--- a/SWIG/_m2crypto.def
+++ b/SWIG/_m2crypto.def
@@ -1,2 +1,2 @@
EXPORTS
-init__m2crypto
+init_m2crypto
diff --git a/SWIG/_m2crypto.i b/SWIG/_m2crypto.i
index 50be5c3..e491222 100644
--- a/SWIG/_m2crypto.i
+++ b/SWIG/_m2crypto.i
@@ -8,7 +8,7 @@
*
*/
-%module(threads=1) _m2crypto
+%module(threads=1) m2crypto
/* We really don't need threadblock (PyGILState_Ensure() etc.) anywhere.
Disable threadallow as well, only enable it for operations likely to
block. */
diff --git a/setup.py b/setup.py
index bac6f9f..fc89513 100644
--- a/setup.py
+++ b/setup.py
@@ -17,9 +17,22 @@ import os, sys, platform
from setuptools import setup
from setuptools.command import build_ext
+from distutils.util import get_platform
from distutils.core import Extension
from distutils.spawn import find_executable
+from distutils.command.build import build
+from setuptools.command.install import install
+
+class CustomBuild(build):
+ def run(self):
+ self.run_command('build_ext')
+ build.run(self)
+
+class CustomInstall(install):
+ def run(self):
+ self.run_command('build_ext')
+ self.do_egg_install()
class _M2CryptoBuildExt(build_ext.build_ext):
'''Specialization of build_ext to enable swig_opts to inherit any
@@ -70,11 +83,12 @@ class _M2CryptoBuildExt(build_ext.build_ext):
self.add_multiarch_paths()
- opensslIncludeDir = os.path.join(self.openssl, 'include')
+ includeDir = os.path.join(self.openssl, 'include')
+ opensslIncludeDir = os.path.join(self.openssl, 'include', 'openssl')
opensslLibraryDir = os.path.join(self.openssl, 'lib')
self.swig_opts = ['-I%s' % i for i in self.include_dirs + \
- [opensslIncludeDir, os.path.join(opensslIncludeDir, "openssl")]]
+ [opensslIncludeDir, includeDir]]
self.swig_opts.append('-includeall')
self.swig_opts.append('-modern')
@@ -85,6 +99,9 @@ class _M2CryptoBuildExt(build_ext.build_ext):
elif platform.architecture()[0] == '32bit':
self.swig_opts.append('-D__i386__')
+ self.swig_opts.append('-outdir')
+ self.swig_opts.append(os.path.join(os.getcwd(),'M2Crypto'))
+
self.include_dirs += [os.path.join(self.openssl, opensslIncludeDir),
os.path.join(os.getcwd(), 'SWIG')]
@@ -103,7 +120,7 @@ if sys.platform == 'darwin':
else:
my_extra_compile_args = []
-m2crypto = Extension(name = 'M2Crypto.__m2crypto',
+m2crypto = Extension(name = 'M2Crypto._m2crypto',
sources = ['SWIG/_m2crypto.i'],
extra_compile_args = ['-DTHREADING'] + my_extra_compile_args,
#extra_link_args = ['-Wl,-search_paths_first'], # Uncomment to build Universal Mac binaries
@@ -145,5 +162,5 @@ interface.''',
ext_modules = [m2crypto],
test_suite='tests.alltests.suite',
- cmdclass = {'build_ext': _M2CryptoBuildExt}
+ cmdclass = {'build': CustomBuild, 'install': CustomInstall, 'build_ext': _M2CryptoBuildExt}
)
--
2.4.1

@ -0,0 +1,69 @@
From 0f2c82f097cf6d3722b7793fe1159160f3f52725 Mon Sep 17 00:00:00 2001
From: Mike Gilbert <floppym@gentoo.org>
Date: Mon, 25 May 2015 12:08:47 -0400
Subject: [PATCH] Gentoo-specific packaging fixes
Fix cross-compiles
EPREFIX support
---
setup.py | 20 ++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)
diff --git a/setup.py b/setup.py
index fc89513..8360e7e 100644
--- a/setup.py
+++ b/setup.py
@@ -32,7 +32,7 @@ class CustomBuild(build):
class CustomInstall(install):
def run(self):
self.run_command('build_ext')
- self.do_egg_install()
+ install.run(self)
class _M2CryptoBuildExt(build_ext.build_ext):
'''Specialization of build_ext to enable swig_opts to inherit any
@@ -81,29 +81,19 @@ class _M2CryptoBuildExt(build_ext.build_ext):
build_ext.build_ext.finalize_options(self)
- self.add_multiarch_paths()
-
includeDir = os.path.join(self.openssl, 'include')
opensslIncludeDir = os.path.join(self.openssl, 'include', 'openssl')
opensslLibraryDir = os.path.join(self.openssl, 'lib')
- self.swig_opts = ['-I%s' % i for i in self.include_dirs + \
- [opensslIncludeDir, includeDir]]
+ eprefix = os.getenv('EPREFIX', '')
+ self.swig_opts = ['-I' + eprefix + '/usr/include']
self.swig_opts.append('-includeall')
self.swig_opts.append('-modern')
- # Fedora does hat tricks.
- if platform.linux_distribution()[0] in ['Fedora', 'CentOS']:
- if platform.architecture()[0] == '64bit':
- self.swig_opts.append('-D__x86_64__')
- elif platform.architecture()[0] == '32bit':
- self.swig_opts.append('-D__i386__')
-
self.swig_opts.append('-outdir')
self.swig_opts.append(os.path.join(os.getcwd(),'M2Crypto'))
- self.include_dirs += [os.path.join(self.openssl, opensslIncludeDir),
- os.path.join(os.getcwd(), 'SWIG')]
+ self.include_dirs += [os.path.join(os.getcwd(), 'SWIG')]
if sys.platform == 'cygwin':
# Cygwin SHOULD work (there's code in distutils), but
@@ -113,8 +103,6 @@ class _M2CryptoBuildExt(build_ext.build_ext):
# Someday distutils will be fixed and this won't be needed.
self.library_dirs += [os.path.join(self.openssl, 'bin')]
- self.library_dirs += [os.path.join(self.openssl, opensslLibraryDir)]
-
if sys.platform == 'darwin':
my_extra_compile_args = ["-Wno-deprecated-declarations"]
else:
--
2.4.1

@ -1,14 +1,3 @@
diff --git a/CHANGES b/CHANGES
index 8355a94..4f14a9a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+Patch
+- X509 calculated extensions work, patch by Carlos Neves
+
0.21.1 - 2011-01-15
-------------------
- Distribution fix
diff --git a/M2Crypto/X509.py b/M2Crypto/X509.py
index eef83fe..f64289e 100644
--- a/M2Crypto/X509.py
@ -253,180 +242,3 @@ index 0471f68..a1a5212 100644
%}
/* Free malloc'ed return value for x509_name_oneline */
diff --git a/demo/x509/calc_extensions.py b/demo/x509/calc_extensions.py
new file mode 100644
index 0000000..136ff86
--- /dev/null
+++ b/demo/x509/calc_extensions.py
@@ -0,0 +1,118 @@
+from M2Crypto import *
+import time
+
+
+#!/bin/bash
+
+## Create Root private key.
+#openssl genrsa -out rootCA.key 2048
+
+def callback(*args):
+ pass
+
+rsa = RSA.gen_key(2048, 65537, callback)
+rsa.save_key('rootCA2.key', None)
+
+#
+## Create self-signed Root certificate.
+#openssl req -config openssl.cnf -new \
+# -x509 -extensions root_ext \
+# -key rootCA.key -out rootCA.crt \
+# -subj "/C=GB/O=m2crypto/CN=Root CA" -set_serial 1
+
+exts = (('basicConstraints','critical, CA:TRUE'),
+ ('keyUsage','cRLSign, keyCertSign, keyEncipherment, nonRepudiation, digitalSignature'),
+ ('subjectKeyIdentifier','hash'),
+ ('authorityKeyIdentifier','keyid,issuer:always'),
+ ('crlDistributionPoints','URI:http://ca.fcpl.com/subord4CA.crl'),
+ ('nsCertType','sslCA, emailCA, objCA'),
+ )
+
+root_priv = EVP.load_key('rootCA2.key')
+root_ca = X509.X509()
+root_ca.set_pubkey(root_priv)
+root_ca.set_serial_number(1)
+name = X509.X509_Name()
+name.C = 'GB'
+name.O = 'm2crypto'
+name.CN = 'Root CA'
+t = long(time.time()) + time.timezone
+now = ASN1.ASN1_UTCTIME()
+now.set_time(t)
+nowPlusYear = ASN1.ASN1_UTCTIME()
+nowPlusYear.set_time(t + 60 * 60 * 24 * 365)
+root_ca.set_not_before(now)
+root_ca.set_not_after(nowPlusYear)
+root_ca.set_subject_name(name)
+root_ca.set_issuer_name(root_ca.get_subject())
+for k,v in exts:
+ root_ca.add_ext(X509.new_extension(k,v))
+
+root_ca.sign(root_priv, 'sha1')
+root_ca.save_pem('rootCA2.crt')
+
+#
+#mkdir certs_db
+#touch index.txt
+#echo 02 > serial
+#
+# Create Subord private key.
+#openssl genrsa -out subordCA.key 2048
+
+rsa = RSA.gen_key(2048, 65537, callback)
+rsa.save_key('suborbCA.key', None)
+
+
+#
+## Create Subord request.
+#openssl req -config openssl.cnf -new \
+# -key subordCA.key -out subordCA.csr \
+# -subj "/C=GB/O=m2crypto/CN=SubOrd CA"
+
+sub_priv = EVP.load_key('rootCA2.key')
+sub_req = X509.Request()
+sub_req.set_pubkey(sub_priv)
+name = X509.X509_Name()
+name.C = 'GB'
+name.O = 'm2crypto'
+name.CN = 'SubOrd CA'
+sub_req.set_subject_name(name)
+sub_req.sign(sub_priv, 'sha1')
+sub_req.save_pem('subordCA2.csr')
+
+
+# Sign Subord request with Root CA.
+#openssl ca -config openssl.cnf \
+# -extensions subord_ext \
+# -in subordCA.csr -out subordCA.crt
+
+exts = (('basicConstraints','critical, CA:TRUE, pathlen:0'),
+ ('keyUsage','cRLSign, keyCertSign, keyEncipherment, nonRepudiation, digitalSignature'),
+ ('subjectKeyIdentifier','hash'),
+ ('authorityKeyIdentifier','keyid,issuer:always'),
+ ('crlDistributionPoints','URI:http://ca.fcpl.com/subord4CA.crl'),
+ ('nsCertType','sslCA, emailCA, objCA'),
+ )
+
+req = X509.load_request('subordCA2.csr')
+ca = X509.load_cert('rootCA2.crt')
+
+out = X509.X509()
+out.set_issuer(ca)
+out.set_subject_name(req.get_subject())
+t = long(time.time()) + time.timezone
+now = ASN1.ASN1_UTCTIME()
+now.set_time(t)
+nowPlusYear = ASN1.ASN1_UTCTIME()
+nowPlusYear.set_time(t + 60 * 60 * 24 * 365)
+out.set_not_before(now)
+out.set_not_after(nowPlusYear)
+for k,v in exts:
+ out.add_ext(X509.new_extension(k,v))
+out.set_pubkey(req.get_pubkey())
+out.sign(root_priv, 'sha1')
+out.save_pem('subordCA2.crt')
+
+
+
+
diff --git a/tests/test_x509.py b/tests/test_x509.py
index 7ea86df..0568d61 100644
--- a/tests/test_x509.py
+++ b/tests/test_x509.py
@@ -31,9 +31,11 @@ class X509TestCase(unittest.TestCase):
if not ca:
ext1 = X509.new_extension('subjectAltName', 'DNS:foobar.example.com')
ext2 = X509.new_extension('nsComment', 'Hello there')
+ ext3 = X509.new_extension('subjectKeyIdentifier', 'hash')
extstack = X509.X509_Extension_Stack()
extstack.push(ext1)
extstack.push(ext2)
+ extstack.push(ext3)
x.add_extensions(extstack)
self.assertRaises(ValueError, x.sign, pk, 'sha513')
x.sign(pk,'sha1')
@@ -43,9 +45,15 @@ class X509TestCase(unittest.TestCase):
return x, pk
def test_ext(self):
- self.assertRaises(ValueError, X509.new_extension,
- 'subjectKeyIdentifier', 'hash')
+ ext = X509.new_extension('subjectKeyIdentifier', 'hash')
+ assert isinstance(ext, X509.X509_Extension_Proxy), ext
+ # XXX should check value too
+ self.assertRaises(ValueError, ext)
+ ext = X509.new_extension('authorityKeyIdentifier', 'keyid,issuer:always')
+ assert isinstance(ext, X509.X509_Extension_Proxy), ext
+ # XXX should check value too
ext = X509.new_extension('subjectAltName', 'DNS:foobar.example.com')
+ assert isinstance(ext, X509.X509_Extension), ext
assert ext.get_value() == 'DNS:foobar.example.com'
assert ext.get_value(indent=2) == ' DNS:foobar.example.com'
assert ext.get_value(flag=m2.X509V3_EXT_PARSE_UNKNOWN) == 'DNS:foobar.example.com'
@@ -250,6 +258,8 @@ class X509TestCase(unittest.TestCase):
cert.set_pubkey(pkey)
ext = X509.new_extension('basicConstraints', 'CA:TRUE')
cert.add_ext(ext)
+ cert.add_ext(X509.new_extension('subjectKeyIdentifier', 'hash'))
+ cert.add_ext(X509.new_extension('authorityKeyIdentifier', 'keyid,issuer:always'))
cert.sign(pk, 'sha1')
if m2.OPENSSL_VERSION_NUMBER >= 0x0090800fL:
@@ -268,6 +278,9 @@ class X509TestCase(unittest.TestCase):
def test_mkcacert(self):
cacert, pk, pkey = self.mkcacert()
assert cacert.verify(pkey)
+ ski = cacert.get_ext('subjectKeyIdentifier').get_value()
+ aki = cacert.get_ext('authorityKeyIdentifier').get_value()
+ self.assertEqual('keyid:'+ski, aki.split('\n')[0])
def test_mkproxycert(self):

@ -1,72 +0,0 @@
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-python/m2crypto/m2crypto-0.21.1-r2.ebuild,v 1.1 2014/07/23 16:38:25 floppym Exp $
EAPI=5
PYTHON_COMPAT=( python{2_6,2_7} )
PYTHON_REQ_USE="threads(+)"
inherit distutils-r1
MY_PN="M2Crypto"
DESCRIPTION="M2Crypto: A Python crypto and SSL toolkit"
HOMEPAGE="http://chandlerproject.org/bin/view/Projects/MeTooCrypto http://pypi.python.org/pypi/M2Crypto"
SRC_URI="mirror://pypi/${MY_PN:0:1}/${MY_PN}/${MY_PN}-${PV}.tar.gz"
LICENSE="BSD"
SLOT="0"
KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~x86-fbsd ~x86-freebsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
IUSE="doc examples"
RDEPEND=">=dev-libs/openssl-0.9.8"
DEPEND="${RDEPEND}
>=dev-lang/swig-1.3.28
dev-python/setuptools[${PYTHON_USEDEP}]
doc? ( dev-python/epydoc[${PYTHON_USEDEP}] )"
S="${WORKDIR}/${MY_PN}-${PV}"
# Tests access network, and fail randomly. Bug #431458.
RESTRICT=test
python_prepare_all() {
# use pre-swigged sources
sed -i -e '/sources/s:\.i:_wrap.c:' setup.py || die
# X509 calculated extensions work, patch by Carlos Neves
epatch "${FILESDIR}/m2crypto-extension-work.patch"
distutils-r1_python_prepare_all
}
python_configure_all() {
set -- swig -python -includeall -I/usr/include \
-o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i
echo "${@}" >&2
"${@}" || die 'swig failed'
}
python_compile_all() {
if use doc; then
cd doc || die
epydoc --html --output=api --name=M2Crypto M2Crypto || die
fi
}
python_test() {
esetup.py test
}
python_install_all() {
use doc && local HTML_DOCS=( doc/. )
distutils-r1_python_install_all
if use examples; then
docinto examples
dodoc -r demo/.
docompress -x /usr/share/doc/${PF}/examples
fi
}

@ -0,0 +1,42 @@
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
EAPI=5
PYTHON_COMPAT=( python2_7 )
PYTHON_REQ_USE="threads(+)"
inherit distutils-r1
MY_PN="M2Crypto"
DESCRIPTION="M2Crypto: A Python crypto and SSL toolkit"
HOMEPAGE="https://github.com/martinpaljak/M2Crypto https://pypi.python.org/pypi/M2Crypto"
SRC_URI="mirror://pypi/${MY_PN:0:1}/${MY_PN}/${MY_PN}-${PV}.tar.gz"
LICENSE="BSD"
SLOT="0"
KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~x86-freebsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
IUSE=""
RDEPEND=">=dev-libs/openssl-0.9.8:0="
DEPEND="${RDEPEND}
>=dev-lang/swig-1.3.28:0
dev-python/setuptools[${PYTHON_USEDEP}]
"
S="${WORKDIR}/${MY_PN}-${PV}"
# Tests access network, and fail randomly. Bug #431458.
RESTRICT=test
PATCHES=(
"${FILESDIR}"/0.22.3-Use-swig-generated-python-loader.patch
"${FILESDIR}"/0.22.3-packaging.patch
"${FILESDIR}"/m2crypto-extension-work.patch
)
python_test() {
esetup.py test
}

@ -135,7 +135,7 @@ RDEPEND="
net-libs/dslib
>=dev-python/pyopenssl-0.14[python_targets_python2_7]
dev-libs/openssl
=dev-python/m2crypto-0.21.1-r2[python_targets_python2_7]
=dev-python/m2crypto-0.22.3-r9[python_targets_python2_7]
dev-python/cherrypy[python_targets_python2_7]
dev-python/pytz[python_targets_python2_7]
)

@ -1,5 +1,5 @@
# without the patch does not allow to work with certificates correctly
>dev-python/m2crypto-0.21.1-r2
<dev-python/m2crypto-0.22.3-r9
# mask portage wgetpaste
>app-text/wgetpaste-2.25-r4

Loading…
Cancel
Save