m2ext-0.1/0000775000175000017500000000000011770374056014341 5ustar threebeanthreebean00000000000000m2ext-0.1/LICENSE0000664000175000017500000000243711770373732015354 0ustar threebeanthreebean00000000000000Copyright (c) 2010-2012, Lev Shamardin All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. m2ext-0.1/setup.py0000664000175000017500000000415011770373364016054 0ustar threebeanthreebean00000000000000from distutils.core import setup from distutils.command import build_ext from distutils.core import Extension import os, sys def load_description(): try: f = open('README.rst', 'r') description = f.read() f.close() return description except: return "" class OpensslBuilder(build_ext.build_ext): """ Specialization of build_ext to enable swig_opts to inherit any include_dirs settings made at the command line or in a setup.cfg file """ user_options = build_ext.build_ext.user_options + [ ('openssl=', 'o', 'Prefix for openssl installation location'), ('swig-extra=', None, 'Extra swig options')] def initialize_options(self): build_ext.build_ext.initialize_options(self) self.swig_extra = None if os.name == 'nt': self.libraries = ['ssleay32', 'libeay32'] self.openssl = 'c:\\pkg' else: self.libraries = ['ssl', 'crypto'] self.openssl = '/usr' def finalize_options(self): build_ext.build_ext.finalize_options(self) openssl_include = os.path.join(self.openssl, 'include') openssl_lib = os.path.join(self.openssl, 'lib') self.swig_opts = ['-I%s' % i for i in self.include_dirs + [openssl_include]] + ['-includeall', '-noproxy'] if self.swig_extra is not None: if hasattr(self.swig_extra, 'pop'): self.swig_opts.extend(self.swig_extra) else: self.swig_opts.append(self.swig_extra) self.include_dirs.append(openssl_include) self.library_dirs.append(openssl_lib) m2ext = Extension(name="m2ext._m2ext", sources=["swig/m2ext.i"], extra_compile_args=["-DTHREADING"]) setup( name='m2ext', version='0.1', description='M2Crypto Extensions', long_description=load_description(), author='Lev Shamardin', author_email='shamardin@gmail.com', license='BSD', url='https://github.com/abbot/m2ext', ext_modules = [m2ext], packages=["m2ext"], cmdclass = {'build_ext': OpensslBuilder}, ) m2ext-0.1/PKG-INFO0000664000175000017500000000114011770374056015432 0ustar threebeanthreebean00000000000000Metadata-Version: 1.0 Name: m2ext Version: 0.1 Summary: M2Crypto Extensions Home-page: https://github.com/abbot/m2ext Author: Lev Shamardin Author-email: shamardin@gmail.com License: BSD Description: ============================ m2ext: M2Crypto extensions ============================ This package contains some extended functions which are not (yet) available in `M2Crypto `_ trunk. It should be built using the same SWIG and OpenSSL version as M2Crypto. Platform: UNKNOWN m2ext-0.1/m2ext/0000775000175000017500000000000011770374056015400 5ustar threebeanthreebean00000000000000m2ext-0.1/m2ext/__init__.py0000664000175000017500000000002511770372713017504 0ustar threebeanthreebean00000000000000import SSL import m2 m2ext-0.1/m2ext/m2.py0000664000175000017500000000002511770372713016263 0ustar threebeanthreebean00000000000000from _m2ext import * m2ext-0.1/m2ext/SSL.py0000664000175000017500000000111211770372713016404 0ustar threebeanthreebean00000000000000from M2Crypto import SSL, X509 import _m2ext class Context(SSL.Context): def validate_certificate(self, cert): """ Validate a certificate using this SSL Context """ store_ctx = X509.X509_Store_Context(_m2ext.x509_store_ctx_new(), _pyfree=1) _m2ext.x509_store_ctx_init(store_ctx.ctx, self.get_cert_store().store, cert.x509, None) rc = _m2ext.x509_verify_cert(store_ctx.ctx) if rc < 0: raise SSL.SSLError("Empty context") return rc != 0 m2ext-0.1/README.rst0000664000175000017500000000046511770372713016033 0ustar threebeanthreebean00000000000000============================ m2ext: M2Crypto extensions ============================ This package contains some extended functions which are not (yet) available in `M2Crypto `_ trunk. It should be built using the same SWIG and OpenSSL version as M2Crypto. m2ext-0.1/swig/0000775000175000017500000000000011770374056015312 5ustar threebeanthreebean00000000000000m2ext-0.1/swig/m2ext.i0000664000175000017500000000240611770372713016523 0ustar threebeanthreebean00000000000000%module _m2ext %{ #include #include %} %include %{ #include #include #include #include #if OPENSSL_VERSION_NUMBER >= 0x10000000L #define STACK _STACK #endif %} %rename(x509_store_ctx_new) X509_STORE_CTX_new; extern X509_STORE_CTX *X509_STORE_CTX_new(void); %inline %{ int x509_store_ctx_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509, STACK *chain) { return X509_STORE_CTX_init(ctx, store, x509, (STACK_OF(X509)*)chain); } %} %rename(x509_store_ctx_set_purpose) X509_STORE_CTX_set_purpose; extern int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose); %rename(x509_verify_cert) X509_verify_cert; extern int X509_verify_cert(X509_STORE_CTX *ctx); %rename(x509_extension_get_object) X509_EXTENSION_get_object; extern ASN1_OBJECT * X509_EXTENSION_get_object(X509_EXTENSION *ex); %inline %{ PyObject *x509_extension_get_data(X509_EXTENSION *ex) { ASN1_OCTET_STRING *data = X509_EXTENSION_get_data(ex); return PyString_FromStringAndSize(data->data, data->length); } %} %inline %{ long ssl_ctx_add_extra_chain_cert(SSL_CTX* ctx, X509* x509) { return SSL_CTX_add_extra_chain_cert(ctx, x509); } %}