File indexing completed on 2026-04-10 08:39:02
0001 import os
0002 import sys
0003
0004 import requests
0005 from pandaserver.config import panda_config
0006
0007
0008
0009 def getSecretKey(pandaID):
0010 try:
0011
0012 proxyURLSSL = panda_config.pandaProxy_URLSSL
0013 ca_certs = panda_config.pandaProxy_ca_certs
0014 key_file = os.environ["X509_USER_PROXY"]
0015 cert_file = os.environ["X509_USER_PROXY"]
0016
0017 data = {"pandaID": pandaID}
0018 res = requests.post(
0019 proxyURLSSL + "/insertSecretKeyForPandaID",
0020 data=data,
0021 verify=ca_certs,
0022 cert=(cert_file, key_file),
0023 )
0024 tmpDict = res.json()
0025 statusCode = tmpDict["errorCode"]
0026 secretKey = tmpDict["secretKey"]
0027 if tmpDict["errorCode"] == 0:
0028
0029 return secretKey, ""
0030 else:
0031
0032 return None, tmpDict["errorDiag"]
0033 except Exception:
0034 errType, errValue = sys.exc_info()[:2]
0035 return None, f"{errType}:{errValue}"