m2crypto

Script works on AWS EC2, but not on AWS Lambda after zipping

╄→尐↘猪︶ㄣ 提交于 2019-12-13 20:25:27
问题 I am creating a simple AWS Lambda function using M2Crypto library. I followed the steps for creating deployment package from here. The lambda function works perfectly on an EC2 Linux instance (AMI). This is my Function definition: CloudOAuth.py from M2Crypto import BIO, RSA, EVP def verify(event, context): pem = "-----BEGIN PUBLIC KEY-----\n{0}\n-----END PUBLIC KEY-----".format("hello") bio = BIO.MemoryBuffer(str.encode(pem)) print(bio) return Deployment Package structure: When I run the

Loading a DER-encoded RSA key using M2Crypto

自作多情 提交于 2019-12-13 15:22:11
问题 The method M2Crypto.RSA.RSA().save_key_der() can be used to save a key in the DER format. However, I do not see a corresponding method M2Crypto.RSA.load_key_der() as I would expect. Is there a way to load a DER-encoded RSA key using M2Crypto? 回答1: The PEM format is base64-encoded DER data with some additional header and footer lines. You can just read DER as binary, transform it to PEM and pass that to RSA.load_key_string : import base64 from M2Crypto import RSA TEMPLATE = """ -----BEGIN RSA

How do you verify an RSA SHA1 signature in pyOpenSSL

孤街醉人 提交于 2019-12-12 23:18:30
问题 I tried installing M2Crypto and facing problems. I don't want to force my customers to use such libraries which are difficult to install. So, I thought I would give pyOpenSSL a try. I am able to get the public key from pem certificate but am not able to find any way to verify the signature. 回答1: You simply can't do this with pyOpenSSL. It is a very limited wrapper around openssl library. But I have a guess what's wrong with building M2Crypto on your host. Try running: export SWIG_FEATURES=-I

Where should I store M2Crypto files

我与影子孤独终老i 提交于 2019-12-12 03:53:18
问题 I am using pyCharm. I ran the windowss installer of M2CryptoWin64 from: https://pypi.python.org/pypi/M2CryptoWin64 I first navigated to the location where I downloaded the M2CryptoWin64 (different location than the python file) and typed this command: pip install --egg M2CryptoWin64 I successfully installed it. However, when I run my python scrypt, I get the following errors: Traceback (most recent call last): File "C:\Users\xxx\PycharmProjects\TLSscanner\scanner_v1.py", line 1, in <module>

Issue using M2Crypto on lambda (works on EC2)

浪尽此生 提交于 2019-12-12 01:22:30
问题 I am trying to install a python function using M2Crypto in AWS Lambda. I spun up an EC2 instance with the Lambda AMI image, installed M2Crypto into a virtualenv, and was able to get my function working on EC2. Then I zipped up the site-package and uploaded to Lambda. I got this error Unable to import module 'epd_M2Crypto': /var/task/M2Crypto/_m2crypto.cpython-36m-x86_64-linux-gnu.so: symbol sk_deep_copy, version libcrypto.so.10 not defined in file libcrypto.so.10 with link time reference

importing m2crypto to google app engine

馋奶兔 提交于 2019-12-11 23:09:48
问题 Hey, I'm having a bit of trouble importing m2crypto to google app engine. I think I know the problem but don't know how to fix it. Anyway, here's my directory structure. mysite/ app.yaml main.py urls.py ... M2Crypto/ __init.py__ (I think the problem is here) EVP.py ... SWIG/ (there is no __init.py___ file here) _m2crypto.i ... When I do this from M2Crypto import EVP , I get an error message that says <type 'exceptions.ImportError'>: No module named __m2crypto . This error is in the __init.py_

problems installing M2Crypto on Mint

谁说我不能喝 提交于 2019-12-11 04:19:28
问题 I am trying to install M2Crypto for python on Mint 12. I have executed `python setup.py build, but the build fails, stating error: command 'gcc' failed with exit status 1 the preceding 2 lines show that there may be a problem with Python.h: SWIG/_m2crypto_wrap.c:126:20: fatal error: Python.h: No such file or directory compilation terminated If anyone knows what needs to be done to fix this, please let me know. EDIT I have attempted to install python-dev , but I get the following error: The

M2Crypto Diffie-Hellman parameters as .pem

半世苍凉 提交于 2019-12-11 03:35:26
问题 What is the M2Crypto equivalent of this openssl cli command? openssl dhparam -out dh.pem 2048 My attempt Looking through the test cases I can generate diffie-hellman parameters as such: >>> import M2Crypto.DH >>> params = M2Crypto.DH.gen_params(2048, 2, lambda: None) I cannot, however, generate a .pem representation of these params. There doesn't appear to be a method to do so on the DH object: >>> help(params) Help on instance of DH in module M2Crypto.DH: class DH | Object interface to the

How do I create a M2Crypto DSA object given parameters and key values?

痴心易碎 提交于 2019-12-11 02:37:54
问题 Using M2Crypto I'd like to create a DSA_pub object for verifying a DSA signature. I know q, p, g, and the public key, but the only way I know to instantiate a DSA object is using: dsa = DSA.set_params(q,p,g) dsa.gen_key() How do I assign the known public key? 回答1: I just ran across exactly this challenge, where I have the P, Q, G and Y parameters (in my case from an XML document), but M2Crypto does not have a way for me to create a valid public key from them. I resorted to using pyasn1 to

Simulating Python's M2Crypto sign algorithm in Haskell

时间秒杀一切 提交于 2019-12-10 21:44:46
问题 I am trying to produce an RSA signature in Haskell that will match the same signature from Python's M2Crypto. I think my issue is the fact that Codec.Crypto.RSA is using the PKCS1 v1.5 algorithm and M2Crypto is using something different. In fact, when using PKCS1 v1.5 in Python, I get the same results as Haskell. How can I sign using the same algorithm as M2Crypto? This seems like it may be helpful, but I'm not able to figure out how to apply it - M2crypto signature "algorithm" Below are my