Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

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

Song Kylin0731db8c2236
diff --git a/api/libs/rsa.py b/api/libs/rsa.py
index da279eb32b8..ed7a0eb1164 100644
--- a/api/libs/rsa.py
+++ b/api/libs/rsa.py
@@ -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)