In a AWS Lambda function that uses the python cryptography
module, possibly as a dependency of the pyOpenSSL
module,
you get the error
cannot import name certificate_transparency
Or alternatively you get an error like this
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "cryptography/x509/__init__.py", line 8, in <module>
from cryptography.x509.base import (
File "cryptography/x509/base.py", line 16, in <module>
from cryptography.x509.extensions import Extension, ExtensionType
File "cryptography/x509/extensions.py", line 18, in <module>
from cryptography.hazmat.primitives import constant_time, serialization
File "cryptography/hazmat/primitives/constant_time.py", line 9, in <module>
from cryptography.hazmat.bindings._constant_time import lib
ImportError: libffi-45372312.so.6.0.4: cannot open shared object file: No such file or directory
One possible cause of this is that when you produced the zip
file containing the cryptography
module and your
Lambda code to upload to AWS Lambda, you used a command like this to create the zip
zip -r ~/lambda_function.zip *
The problem is using *
skips hidden files beginning with the .
character. One of those files is
.libs_cffi_backend
This file, when missing causes the errors shown above
When creating the lambda_function, use .
instead of *
like this
zip -r ~/lambda_function.zip .
worked great. thanks!