r130 - 04 Feb 2014 - 20:55:58 - HeikkiToivonenYou are here: OSAF >  Projects Web  >  DevelopmentHome > MeTooCrypto


As of summer 2013 the maintainer has been Martin Paljak. The new home page is https://github.com/martinpaljak/M2Crypto.

M2Crypto is the most complete Python wrapper for OpenSSL featuring RSA, DSA, DH, HMACs, message digests, symmetric ciphers (including AES); SSL functionality to implement clients and servers; HTTPS extensions to Python's httplib, urllib, and xmlrpclib; unforgeable HMAC'ing AuthCookies for web session management; FTP/TLS client and server; S/MIME; ZServerSSL: A HTTPS server for Zope and ZSmime: An S/MIME messenger for Zope. M2Crypto can also be used to provide SSL for Twisted.

M2Crypto's unit tests cover over 80% of the Python code.

The original M2Crypto homepage is at http://sandbox.rulemaker.net/ngps/m2/. It hasn't been updated since M2Crypto 0.13.1 release.

Discuss M2Crypto on comp.lang.python newsgroup or python-list mailinglist. You can also get questions answered on stackoverflow.com (please tag questions with m2crypto tag). M2Crypto used to be discussed on the public python-crypto mailing list, but it is no longer the preferred forum. See http://listserv.surfnet.nl/archives/python-crypto.html for archives and subscription information.

M2Crypto was started and mostly developed by Ng Pheng Siong. Next maintainer was Heikki Toivonen (heikki@osafoundation.org). Heikki's blog contains updates on M2Crypto depevelopment.

As of summer 2013 the maintainer has been Martin Paljak. The new home page is https://github.com/martinpaljak/M2Crypto.

OSAF is providing limited hosting to the M2Crypto project - see below for details.

The rest of the page is provided for historical purposes, please see current home page.


Note these are obsolete!


Contributed Builds

These are provided by volunteers, untested by M2Crypto author. Feel free to add contributed build links. Please mention the configuration (platform, python version, openssl version, your name and preferably also your email address). You need to register on this wiki to be able to edit.



  • Python 2.3 or newer
    • m2urllib2 requires Python 2.4 or newer
  • OpenSSL 0.9.7 or newer
    • Some optional new features will require OpenSSL 0.9.8 or newer
  • SWIG 1.3.28 or newer required for building
    • SWIG 1.3.30 or newer may be required with Python 2.5 or newer and Python 2.4 with Py_ssize_t patches


Recommended reading for anyone using OpenSSL or any OpenSSL wrappers: "Network Security with OpenSSL" by John Viega, Matt Messier and Pravir Chandra, ISBN 059600270X.

SSL in Python 2.6 is a good overview of the status of SSL in Python 2.6 and later.

How to build M2Crypto on Windows by Eli Golovinsky

There are some old, minimal HOWTO documents in the doc/ directory:

Generated API Documentation

Unit tests and demo scripts are also useful learning tools. You can also easily generate API documentation for M2Crypto using Epydoc.

  1. Install Epydoc 3.0.1 or later, setuptools and optionally Graphviz
  2. cd M2Crypto source tree
  3. python setup build test
  4. epydoc --no-private --config=epydoc.conf

This will create api/ directory under doc/. Open the index.html file in your browser.

Epydoc takes a lot of optional arguments and options in the config file that you may wish to experiment with.

OpenSSL documentation can be used as well, you just have to figure out the actual OpenSSL APIs called.

Finally, here is a comparison of Python cryptography modules (PDF) which includes a nice feature list for M2Crypto.

Bugzilla database

Please note that OSAF's Bugzilla installation has several products, and M2Crypto is but one of them. Take that into account when you search for bugs and file new bugs.

List all open M2crypto bugs.

File an M2Crypto bug (advanced).


Release Checklist

  • Announce approximate release schedule on python-crypto mailinglist, leaving room for at least 4 one week betas before the final bits.
  • Before first beta create branch; create beta and release tags from branch
  • Run unit tests for bits about to be packaged
  • Check out fresh source with svn export, create tar.gz tarball on homepage, update sections and links
  • Upload release to cheeseshop.python.org with PGP signature
  • Announce
    • beta
      • python-crypto
      • blog
    • release
      • python-crypto
      • freshmeat.net
      • blog
      • comp.lang.python and comp.lang.python.announce

Projects Using M2Crypto

Feel free to update!

Related Projects



Q: I get an error initializing SSL.Context:

Traceback (most recent call last):
  File ".../M2Crypto/SSL/Context.py", line 43, in __init__
    map()[long(self.ctx)] = self
ValueError: invalid literal for long(): _480e1008_p_SSL_CTX 

A: Your version of SWIG is too old. The minimum required is 1.3.28.

Q: I get a typedef error during build:

_lib.h:5: error: redefinition of typedef 'Py_ssize_t'

A: It has been reported this was a problem with SWIG 1.3.30rc1, but that it works in 1.3.30 and newer.

Q: M2Crypto crashes/does not work in my multi-threaded application.

A: You need to call M2Crypto.threading.init() to initialize threading mode before use, and cleanup() to end threading support.

Q: I have OpenSSL in non-standard location, how can I build M2Crypto?

A: build_ext takes --openssl option to specify openssl directory prefix. However, there have been some reports that this is not always enough, and you need to also explicitly specify --library-dirs and --include-dirs options. So the full build and install command would be something like: python setup.py build_ext --openssl=<openssl prefix> --library-dirs=<openssl prefix>/lib --include-dirs=<openssl prefix>/include build install.

Q: I still can't build on a Fedora Core -based system, any workarounds?

A: Use the fedora_setup.sh wrapper script: ./fedora_setup.sh [setup.py options]


Q: Why is OSAF providing limited hosting to M2Crypto?

A: M2Crypto did not have public source repository nor bug database, which made it hard to contribute to it and keep track of issues. M2crypto is an integral part of OSAF's Chandler application and we have made and will continue to make changes to it, but we did not want to fork M2Crypto. We believe everyone will benefit by working on and improving the same official version.

Q: Will you host M2Crypto permanently?

A: We'll provide hosting as long as needed and/or we are able to do so. If some other hosting arrangement makes sense, we can switch to that in the future.

Q: My project X does not have a public source archive or Bugzilla, can you provide hosting for it?

A: Short answer: no. We do not intend to become a project hosting facility. We made an exception with M2Crypto because we use it in Chandler and intend to make lots of changes. If your project is used in Chandler and we feel like we would need to modify it a lot, we could consider it. But even then we'd ask you to first see if you could use some public project hosting facility like SourceForge.

Q: How can I edit this page?

A: You need to register on this wiki to be able to edit.

toggleopenShow attachmentstogglecloseHide attachments
Topic attachments
I Attachment Action Size Date Who Comment
elsegz m2crypto-0.18.1.tar.gz manage 377.0 K 08 Oct 2007 - 13:28 HeikkiToivonen nothing works today...
elsegz m2crypto-0.18.2.tar.gz manage 377.1 K 12 Oct 2007 - 15:03 HeikkiToivonen  
exeexe M2Crypto-0.18.2.win32-py2.5.exe manage 743.3 K 22 Feb 2008 - 02:10 MikkoHiltunen  
elseegg M2Crypto-0.18.2-py2.5-macosx-10.5-i386.egg manage 373.2 K 24 Apr 2008 - 12:51 FlorentAide MacosX? 10.5 egg compiled against OpenSSL? 0.9.7l
exeexe M2Crypto-0.19.win32-py2.5.exe manage 754.4 K 10 Oct 2008 - 06:21 MikkoHiltunen compiled with MinGW? against OpenSSL? 0.9.8i, dll:s included
exeexe M2Crypto-0.19.1.win32-py2.5.exe manage 888.7 K 28 Mar 2009 - 19:41 KeLLey compiled with MinGW(gcc-3.4.5) against OpenSSL 0.9.8k, dll's included(depend on MSVCR71.dll,zlib available)
exeexe M2Crypto-0.19.1.win32-py2.6.exe manage 883.5 K 28 Mar 2009 - 21:20 KeLLey compiled with MinGW(gcc-3.4.5) against OpenSSL 0.9.8k, dll's included(depend on MSVCR90.dll,zlib available)
exeexe M2Crypto-0.20.2.win32-py2.7.exe manage 339.3 K 27 Oct 2010 - 04:22 MaliciousWizard M2Crypto-0.20.2 build for Python2.7 with MSVC2008, bdist_wininst version
elseegg M2Crypto-0.20.2-py2.7-win32.egg manage 239.6 K 27 Oct 2010 - 04:23 MaliciousWizard M2Crypto-0.20.2 build for Python2.7 with MSVC2008, bdist_egg version
zipzip M2Crypto-0.20.2.win32.zip manage 243.8 K 27 Oct 2010 - 04:25 MaliciousWizard M2Crypto-0.20.2 build for Python2.7 with MSVC2008, bdist version
elseegg M2Crypto-0.20.2-py2.6-linux-x86_64.egg manage 462.2 K 06 Jan 2011 - 14:11 JeromeCollette (compiled with GCC 4.4.5 against OpenSSL? 0.9.8), 'bdist_egg' version.
elsemsi M2Crypto-0.21.1.win32-py2.7.msi manage 304.0 K 18 Jan 2011 - 14:58 CsabaToth Built with Python 2.7.1 32 bit, OpenSSL? 1.0.0c, MSVC2008, MSI Installer version
elseegg M2Crypto-0.21.1-py2.5-macosx-10.5-i386.egg manage 420.2 K 25 Jan 2011 - 11:27 JustinMcWilliams M2Crypto 0.21.1, built with Python2.5 MacOSX?-10.5-i386 OpenSSL? 0.9.7
elseegg M2Crypto-0.21.1-py2.6-macosx-10.6-universal.egg manage 608.7 K 25 Jan 2011 - 11:30 JustinMcWilliams M2Crypto 0.21.1, built with Python2.6 MacOSX?-10.6-universal OpenSSL? 0.9.8
elseegg M2Crypto-0.21.1-py2.7-macosx-10.7-intel.egg manage 484.3 K 04 Mar 2011 - 08:34 JohnRandolph M2Crypto built with OS X 10.7, i686-apple-darwin11-llvm-gcc-4.2, swig 2.0.2
exeexe M2Crypto-0.21.1.win32-py2.6.exe manage 340.4 K 21 Apr 2011 - 02:33 FlierLu compiled with Mingw 32bit against openssl-1.0.0d, Python 2.6
zipzip openssl-1.0.0d-win32.zip manage 599.1 K 21 Apr 2011 - 02:35 FlierLu OpenSSL? 1.0.0d compiled with VS2010 for Win32
exeexe Spark.exe manage 423.5 K 29 Feb 2012 - 05:18 SebastienHUYNH  
exeexe M2Crypto-0.21.1.win-amd64-py2.7.exe manage 1198.6 K 22 Mar 2012 - 20:53 JasonStevens M2Crypto-0.21.1 build for Python2.7.2 with MSVC2008, OpenSSL? 1.0.1, bdist_wininst version
exeexe M2Crypto-0.21.1.win32-py2.7.exe manage 1019.6 K 22 Mar 2012 - 21:02 JasonStevens M2Crypto-0.21.1 build for Python2.7.2 with MSVC2008, OpenSSL?? 1.0.1, bdist_wininst version 32bit
elseegg M2Crypto-0.21.1-py2.7-macosx-10.8-intel.egg manage 477.5 K 26 Mar 2012 - 14:14 JustinMcWilliams M2Crypto built with OS X 10.8, i686-apple-darwin11-llvm-gcc-4.2, swig 2.0.4
elseegg M2Crypto-0.21.1-py2.5-macosx-10.6-i386.egg manage 446.4 K 12 Apr 2012 - 09:01 JohnRandolph M2Crypto 0.21.1 py2.5 OS X 10.6
elseegg M2Crypto-0.21.1-py2.5-macosx-10.7-x86_64.egg manage 309.7 K 12 Apr 2012 - 09:04 JohnRandolph M2Crypto 0.21.1 py2.5 OS X 10.7
elseegg M2Crypto-0.21.1-py2.5-macosx-10.8-x86_64.egg manage 304.0 K 12 Apr 2012 - 11:38 JohnRandolph M2Crypto 0.21.1 py2.5 OS X 10.8
elseegg M2Crypto-0.21.1-py2.6-macosx-10.7-intel.egg manage 484.5 K 14 Nov 2012 - 12:14 JustinMcWilliams compiled with OS X 10.7: i686-apple-darwin11-llvm-gcc-4.2, Python 2.6, swig 2.0.4, OpenSSL? 0.9.8r
elseegg M2Crypto-0.21.1-py2.6-macosx-10.8-intel.egg manage 477.4 K 14 Nov 2012 - 12:14 JustinMcWilliams compiled with OS X 10.8: i686-apple-darwin11-llvm-gcc-4.2, Python 2.6, swig 2.0.4, OpenSSL? 0.9.8r
elseegg M2Crypto-0.21.1-py2.7-macosx-10.9-intel.egg manage 410.8 K 26 Aug 2013 - 08:56 JustinMcWilliams M2Crypto-0.21.1 build for Python2.7.5
elseegg M2Crypto-0.21.1-py2.6-macosx-10.9-intel.egg manage 411.1 K 26 Aug 2013 - 09:16 JustinMcWilliams M2Crypto-0.21.1 build for py2.6 on OS X 10.9
Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r130 < r129 < r128 < r127 < r126 | More topic actions
Open Source Applications Foundation
Except where otherwise noted, this site and its content are licensed by OSAF under an Creative Commons License, Attribution Only 3.0.
See list of page contributors for attributions.