fix: private.pem keyPath error in windows (#22814)
Co-authored-by: songkunling <songkunling@cabrtech.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import hashlib
|
||||
import os
|
||||
from typing import Union
|
||||
|
||||
from Crypto.Cipher import AES
|
||||
@@ -17,7 +18,7 @@ def generate_key_pair(tenant_id: str) -> str:
|
||||
pem_private = private_key.export_key()
|
||||
pem_public = public_key.export_key()
|
||||
|
||||
filepath = "privkeys/{tenant_id}".format(tenant_id=tenant_id) + "/private.pem"
|
||||
filepath = os.path.join("privkeys", tenant_id, "private.pem")
|
||||
|
||||
storage.save(filepath, pem_private)
|
||||
|
||||
@@ -47,7 +48,7 @@ def encrypt(text: str, public_key: Union[str, bytes]) -> bytes:
|
||||
|
||||
|
||||
def get_decrypt_decoding(tenant_id: str) -> tuple[RSA.RsaKey, object]:
|
||||
filepath = "privkeys/{tenant_id}".format(tenant_id=tenant_id) + "/private.pem"
|
||||
filepath = os.path.join("privkeys", tenant_id, "private.pem")
|
||||
|
||||
cache_key = "tenant_privkey:{hash}".format(hash=hashlib.sha3_256(filepath.encode()).hexdigest())
|
||||
private_key = redis_client.get(cache_key)
|
||||
|
Reference in New Issue
Block a user