fix: private.pem keyPath error in windows

pull/22814/head
songkunling 7 months ago
parent 6d3e198c3c
commit 866cf953a1

@ -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)

Loading…
Cancel
Save