mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Default to Cryptodome, fallback to PyCrypto
This commit is contained in:
parent
b2b0764dd4
commit
e6bc9f8e14
1 changed files with 15 additions and 2 deletions
|
@ -63,9 +63,20 @@ try:
|
|||
from M2Crypto import EVP
|
||||
HAS_M2 = True
|
||||
except ImportError:
|
||||
from Crypto.Hash import SHA256
|
||||
from Crypto.Signature import PKCS1_v1_5
|
||||
HAS_M2 = False
|
||||
try:
|
||||
from Cryptodome.Hash import SHA256
|
||||
from Cryptodome.PublicKey import RSA
|
||||
from Cryptodome.Signature import PKCS1_v1_5
|
||||
HAS_REQUIRED_CRYPTO = True
|
||||
except ImportError:
|
||||
try:
|
||||
from Crypto.Hash import SHA256
|
||||
from Crypto.PublicKey import RSA
|
||||
from Crypto.Signature import PKCS1_v1_5
|
||||
HAS_REQUIRED_CRYPTO = True
|
||||
except ImportError:
|
||||
HAS_REQUIRED_CRYPTO = False
|
||||
|
||||
# Import salt libs
|
||||
from salt.ext import six
|
||||
|
@ -118,6 +129,8 @@ def __virtual__():
|
|||
'''
|
||||
Check for Joyent configs
|
||||
'''
|
||||
if HAS_REQUIRED_CRYPTO is False:
|
||||
return False, 'Either PyCrypto or Cryptodome needs to be installed.'
|
||||
if get_configured_provider() is False:
|
||||
return False
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue