fix: resolve Windows path separator issue in Huawei OBS operations (#23475)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
import os
|
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
from Crypto.Cipher import AES
|
from Crypto.Cipher import AES
|
||||||
@@ -18,7 +17,7 @@ def generate_key_pair(tenant_id: str) -> str:
|
|||||||
pem_private = private_key.export_key()
|
pem_private = private_key.export_key()
|
||||||
pem_public = public_key.export_key()
|
pem_public = public_key.export_key()
|
||||||
|
|
||||||
filepath = os.path.join("privkeys", tenant_id, "private.pem")
|
filepath = f"privkeys/{tenant_id}/private.pem"
|
||||||
|
|
||||||
storage.save(filepath, pem_private)
|
storage.save(filepath, pem_private)
|
||||||
|
|
||||||
@@ -48,7 +47,7 @@ def encrypt(text: str, public_key: Union[str, bytes]) -> bytes:
|
|||||||
|
|
||||||
|
|
||||||
def get_decrypt_decoding(tenant_id: str) -> tuple[RSA.RsaKey, object]:
|
def get_decrypt_decoding(tenant_id: str) -> tuple[RSA.RsaKey, object]:
|
||||||
filepath = os.path.join("privkeys", tenant_id, "private.pem")
|
filepath = f"privkeys/{tenant_id}/private.pem"
|
||||||
|
|
||||||
cache_key = f"tenant_privkey:{hashlib.sha3_256(filepath.encode()).hexdigest()}"
|
cache_key = f"tenant_privkey:{hashlib.sha3_256(filepath.encode()).hexdigest()}"
|
||||||
private_key = redis_client.get(cache_key)
|
private_key = redis_client.get(cache_key)
|
||||||
|
Reference in New Issue
Block a user