Search code examples
pythongoogle-app-enginersaamazon-cloudfront

RSA encryption routines for Google App Engine Python


Hey, I'm trying to generate a signed url in python. Basically, I'm trying to access protected Amazon Cloudfront content from a Google App Engine server. Amazon has provided me with a pem file that has content which looks like:

-----BEGIN RSA PRIVATE KEY-----

MIICWQf....a lot more characters...7bx8WiUk

-----END RSA PRIVATE KEY-----

According to Getting started with secure AWS CloudFront streaming with Python, a signed url is generated through EVP as such: key = EVP.load_key_string(priv_key_string). The main problem is that Google App Engine does not support from M2Crypto import EVP. I've tried googling RSA encryption routines Google App Engine but have not found any modules that work. One I stumbled across, Signing a string with RSA private key on Google App Engine Python SDK, said I could use from tlslite.utils import keyfactory. Yet I still get a response that says No module named tlslite.utils.

In summary, I'm just wondering if anyone know's if a module that does RSA encryption routines on Google App Engine. Thanks, your help is greatly appreciated as always


Solution

  • As bossylobster pointed out, what you can do is include the RSA package that you need as a part of your application by copying the package's source code as a sub-directory within your app's directory structure. This gets uploaded to the app-engine service as just another part of your app. As long as the package only uses those standard library modules that app-engine provides in production, it will run as expected. The directory structure would end up looking something like:

    mysite/
        app.yaml
        main.py
        urls.py
        ...
        tlslite/
            __init__.py
            ...