0

I'm trying to zip apple wallet passes on my server using python. Apple provides us with server-side implementation in Ruby, but I have a server running Django.

Every python-implemented library for this purposes I found uses something called M2Crypto for SSL key decryption/encryption. (I've decided to use this implementation)

Because pass-signing library depends on m2Crypto I first tried installing M2Crypto on a Mac to test pass signing locally.

Installation with pip gave nothing but errors.

pip install M2Crypto

After a lot of swearing I found a solution how to install M2Crypto here. The thing is although bash tells me that brew installed M2Crypto my python code still doesn't see this damned M2Crypto library so I can't even begin testing pass zipper locally!

Why doesn't my python code see this library and is there a universal way to install it?

I'm packaging my project to docker image and I need to know how to install it as dependency on docker image.

Stan Reduta
  • 3,292
  • 5
  • 31
  • 55
  • 1
    I don't know about other libraries, but I had similar issues and decided to take the time to roll my own.. First: `brew install openssl` and `brew upgrade openssl` Then try: https://github.com/Brandon-T/PyWallet . This is a library I made from scratch. It compresses a folder into a zip with extension `.pkpass` and signs it as a PKPass that can be distributed on your wallet server.. – Brandon Nov 22 '17 at 01:12
  • @Brandon, that would be great! But how do I get it running inside Docker container? Will it be just enough to do pip install openssl on ubuntu image? Can I contact you somehow to ask couple more questions about your implementation? – Stan Reduta Nov 22 '17 at 01:14
  • I have no idea what Docker is or how it works.. but my code just loads compresses a folder into a PKPass and signs it like Apple's signer. It loads libssl.dylib on OSX or libssl.so on Linux. I run it directly on Linux Mint and it works fine, but I'm not sure what Docker is. No you cannot use pip to install openssl because the library requires the native OpenSSL for signing. AFAIK, pip doesn't include all OpenSSL functions. – Brandon Nov 22 '17 at 02:46
  • Is it not as simple as adding `RUN apt-get update && apt-get install python-m2crypto` into your Dockerfile? (Assuming you are building from a Debian/Ubuntu based image) – PassKit Nov 22 '17 at 06:35
  • 1
    Hi, this is an upstream maintainer of M2Crypto. Unfortunately, I don't have Mac OS X computer myself, so I completely rely on volunteers to help me. The best installation instructions I found are collected in [INSTALL](https://gitlab.com/m2crypto/m2crypto/blob/master/INSTALL.rst). If anybody has anything to add to it, or make M2Crypto completely piip-installable, I would love to get [a merge request](https://gitlab.com/m2crypto/m2crypto/merge_requests/new) or at least [description what to do](https://gitlab.com/m2crypto/m2crypto/issues/new?issue%5Bassignee_id%5D=&issue%5Bmilestone_id%5D=). – mcepl Nov 22 '17 at 09:41
  • @Brandon what package manager do you use to install dependencies on Linux? There's no brew on Linux, so you have to you apt-get or pip for that matter? – Stan Reduta Nov 22 '17 at 10:19
  • "my python code still doesn't see this damned M2Crypto" - what is the output of the command `$ python -c "import M2Crypto"`? – hoefling Nov 22 '17 at 14:47
  • @hoefling I already figured out that python didn't see the library because I was using 3.6 version all the time, and m2crypto is for 2.7 version only. – Stan Reduta Nov 22 '17 at 15:09
  • @mcepl thanks, I looked through your repo yesterday and was searching for a way to contact you. Any chances we can rebuild crypto to support python 3? There's a link to my GitHub account at my stack page, please contact me. – Stan Reduta Nov 22 '17 at 15:57
  • Hi @StanRedoute Did you get this sorted out? although if you are using docker, the issue isn't just about it been py3 or py2, you may have to install it on your docker os using exec, also I do agree that py3 has some sort of issue with m2crypto, but it installs anyway on it. – Ezekiel Sep 02 '18 at 19:06
  • @Ezekiel check out first comment in a thread. It works. – Stan Reduta Sep 02 '18 at 19:09
  • @StanRedoute Thanks, I will just modify my code to use something similar, from his code. – Ezekiel Sep 02 '18 at 21:20

0 Answers0