Closed RockBomber closed 7 years ago
Chances are you're seeing this error because cryptography 2.0+ have binary wheels available that include a version of OpenSSL that does not support GOST. You can check this by doing python -c "from cryptography.hazmat.backends.openssl.backend import backend;print(backend.openssl_version_text())"
. If it outputs 1.1.0f (and not 1.0.1f) you've got the wheel. Try reinstalling with pip install cryptography --no-binary cryptography
.
Thank You for answer!
I checked it:
$ python -c "from cryptography.hazmat.backends.openssl.backend import backend;print(backend.openssl_version_text())"
OpenSSL 1.0.1f 6 Jan 2014
Likely cryptography use an external OpenSSL. Right?
But I also tried to reinstall cryptography:
$ pip uninstall cryptography
Uninstalling cryptography-2.0.3:
/home/asdef/.virtualenvs/autotesting/lib/python2.7/site-packages/cryptography
/home/asdef/.virtualenvs/autotesting/lib/python2.7/site-packages/cryptography-2.0.3-py2.7.egg-info
Proceed (y/n)? y
Successfully uninstalled cryptography-2.0.3
$ pip install cryptography --no-binary cryptography
Collecting cryptography
Downloading cryptography-2.0.3.tar.gz (427kB)
100% |████████████████████████████████| 430kB 1.5MB/s
Requirement already satisfied: idna>=2.1 in /home/asdef/.virtualenvs/autotesting/lib/python2.7/site-packages (from cryptography)
Requirement already satisfied: asn1crypto>=0.21.0 in /home/asdef/.virtualenvs/autotesting/lib/python2.7/site-packages (from cryptography)
Requirement already satisfied: six>=1.4.1 in /home/asdef/.virtualenvs/autotesting/lib/python2.7/site-packages (from cryptography)
Requirement already satisfied: enum34 in /home/asdef/.virtualenvs/autotesting/lib/python2.7/site-packages (from cryptography)
Requirement already satisfied: ipaddress in /home/asdef/.virtualenvs/autotesting/lib/python2.7/site-packages (from cryptography)
Requirement already satisfied: cffi>=1.7 in /home/asdef/.virtualenvs/autotesting/lib/python2.7/site-packages (from cryptography)
Requirement already satisfied: pycparser in /home/asdef/.virtualenvs/autotesting/lib/python2.7/site-packages (from cffi>=1.7->cryptography)
Installing collected packages: cryptography
Running setup.py install for cryptography ... done
Successfully installed cryptography-2.0.3
Again chcked it:
$ python -c "from cryptography.hazmat.backends.openssl.backend import backend;print(backend.openssl_version_text())"
OpenSSL 1.0.1f 6 Jan 2014
But I still have same error:
Traceback (most recent call last):
File "test_pkrbp.py", line 92, in <module>
print 'public_key:', csr.public_key()
File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/cryptography/hazmat/backends/openssl/x509.py", line 364, in public_key
self._backend.openssl_assert(pkey != self._backend._ffi.NULL)
File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 111, in openssl_assert
return binding._openssl_assert(self._lib, ok)
File "/home/asdef/.virtualenvs/autotesting/local/lib/python2.7/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 75, in _openssl_assert
errors_with_text
cryptography.exceptions.InternalError: Unknown OpenSSL error. This error is commonly encountered when another library is not cleaning up the OpenSSL error stack. If you are using cryptography with another library that uses OpenSSL try disabling it before reporting a bug. Otherwise please file an issue at https://github.com/pyca/cryptography/issues with information on how to reproduce this. ([_OpenSSLErrorWithText(code=101310620L, lib=6, func=158, reason=156, reason_text='error:0609E09C:digital envelope routines:PKEY_SET_TYPE:unsupported algorithm'), _OpenSSLErrorWithText(code=185036911L, lib=11, func=119, reason=111, reason_text='error:0B07706F:x509 certificate routines:X509_PUBKEY_get:unsupported algorithm')])
You probably need to call something to initialize the engine/load the default config, but that's outside of the scope of what we can support since cryptography does not (and will not) test against this type of configuration. Good luck!
I successfully loaded my openssl.cnf (including an engine definition similar to @RockBomber's) into my Python app by calling:
from cryptography.hazmat.backends.openssl.backend import backend
backend._lib.OPENSSL_config(backend._ffi.NULL)
Note: OPENSSL_config() is deprecated in OpenSSL 1.1.0+. Not tested, but CONF_modules_load() should work in that case.
[I know it's 2 years late... might still help someone]
Hello!
I have X509Req file with Public Key Algorithm: GOST R 34.10-2001 I had an error with getting pub key:
I enabled GOST in OpenSSL by added lines to file
/etc/ssl/openssl.cnf
:Now I can success get pub key from X509Req file:
But I've still got an error with getting pub key with python-cryptography:
Help please! How to enable GOST in cryptography?
My environment: Ubuntu 14.04 Python 2.7.8 OpenSSL 1.0.1f cryptography 2.0.3 cffi 1.10.0