Quellcode durchsuchen

fix: private.pem keyPath error in windows (#22814)

Co-authored-by: songkunling <songkunling@cabrtech.com>
tags/1.7.1
Song Kylin vor 3 Monaten
Ursprung
Commit
0731db8c22
Es ist kein Account mit der E-Mail-Adresse des Committers verbunden
1 geänderte Dateien mit 3 neuen und 2 gelöschten Zeilen
  1. 3
    2
      api/libs/rsa.py

+ 3
- 2
api/libs/rsa.py Datei anzeigen

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

Laden…
Abbrechen
Speichern