File tree Expand file tree Collapse file tree 1 file changed +2
-10
lines changed
Expand file tree Collapse file tree 1 file changed +2
-10
lines changed Original file line number Diff line number Diff line change 22import requests
33
44from base64 import b64encode
5- from cryptography .hazmat .backends import _available_backends
65from cryptography .hazmat .primitives .ciphers import Cipher
76from cryptography .hazmat .primitives .ciphers .algorithms import AES
87from cryptography .hazmat .primitives .ciphers .modes import ECB
@@ -56,7 +55,8 @@ def init_app(self, app):
5655 return
5756 private_key = app .config .get ('FASTSPRING_PRIVATE_KEY' )
5857 if private_key is not None :
59- self .openssl = openssl_backend ()
58+ from cryptography .hazmat .backends .openssl .backend import backend
59+ self .openssl = backend
6060 with open (private_key , 'rb' ) as fp :
6161 self .private_key = load_pem_private_key (
6262 fp .read (), password = None , backend = self .openssl )
@@ -219,14 +219,6 @@ def __str__(self):
219219 self .response .text )
220220
221221
222- def openssl_backend ():
223- """Return OpenSSL cryptography backend or fail."""
224- for backend in _available_backends ():
225- if backend .name == 'openssl' :
226- return backend
227- raise Exception ('Could not find OpenSSL cryptography backend' )
228-
229-
230222def openssl_private_encrypt (key , data , backend ):
231223 """Encrypt data with RSA private key.
232224
You can’t perform that action at this time.
0 commit comments