Skip to content Skip to sidebar Skip to footer

Obnoxious Cryptographydeprecationwarning Because Of Missing Hmac.compare_time Function Everywhere

Things were running along fine until one of my projects started printing this everywhere, at the top of every execution, at least once: local/lib/python2.7/site-packages/cryptograp

Solution 1:

I hit this error for quite sometime. For my environment, it was a pain to upgrade Python to a higher version than 2.7.6. The easier solution was to downgrade cryptography module using pip:

pip2.7 install cryptography==2.2.2

I think the best solution is to upgrade your python version though

Solution 2:

This answer is for Python3

I got here by looking for an answer while using Paramiko. For those still looking for a simple answer. I got these CryptographyDeprecationWarning suppresed with the these lines of code before importing Paramiko:

import warnings 
warnings.filterwarnings(action='ignore',module='.*paramiko.*')

I hope this helps

Solution 3:

If you want to be more selective about suppressing JUST that particular deprecation warning:

import warnings
from cryptography.utilsimportCryptographyDeprecationWarning
warnings.filterwarnings("ignore", category=CryptographyDeprecationWarning)

Solution 4:

I started getting this warning for a straightforward requests.get call. This warning is printed when the module cryptography.hazmat.primitives.constant_time is loaded, and so this should typically only come once per Python program. If you are seeing it many times, it must be because a Python program (like a utility) is getting executed multiple times. You just have to identify that program and add the below code to the main entry point:

import cryptography
from cryptography import utils
with warnings.catch_warnings():
    warnings.simplefilter('ignore', cryptography.utils.DeprecatedIn23)
    import cryptography.hazmat.primitives.constant_time

Solution 5:

For Python3 only:

Per an apparent Paramiko update this worked for me and solve the similar problem/symptoms I was experiencing:

pip3 install --upgrade paramiko

This installed paramiko 2.6.0 on my system, replacing 2.4.2:

$pip3install--upgradeparamiko
[...]
Installing collected packages:paramikoFound existing installation:paramiko2.4.2Uninstalling paramiko-2.4.2:Successfullyuninstalledparamiko-2.4.2Successfullyinstalledparamiko-2.6.0$

My Python2 environment appears to be messed up, so I'm not able to test this on Python2.

Post a Comment for "Obnoxious Cryptographydeprecationwarning Because Of Missing Hmac.compare_time Function Everywhere"