Load root CA

This commit is contained in:
Pierre HUBERT 2024-06-29 18:08:57 +02:00
parent dca8848ec9
commit 4c4d1e13cb
3 changed files with 21 additions and 2 deletions

View File

@ -6,3 +6,9 @@ def get_secure_origin() -> str:
if res.status_code < 200 or res.status_code > 299: if res.status_code < 200 or res.status_code > 299:
raise Exception(f"Get secure origin failed with status {res.status_code}") raise Exception(f"Get secure origin failed with status {res.status_code}")
return res.text return res.text
def get_root_ca() -> str:
res = requests.get(f"{args.unsecure_origin}/pki/root_ca.pem")
if res.status_code < 200 or res.status_code > 299:
raise Exception(f"Get root CA failed with status {res.status_code}")
return res.text

View File

@ -10,3 +10,4 @@ parser.add_argument("--storage", help="Change storage location", default="storag
args = parser.parse_args() args = parser.parse_args()
args.secure_origin_path = os.path.join(args.storage, "SECURE_ORIGIN") args.secure_origin_path = os.path.join(args.storage, "SECURE_ORIGIN")
args.root_ca_path = os.path.join(args.storage, "root_ca.pem")

View File

@ -17,3 +17,15 @@ if not os.path.isfile(args.secure_origin_path):
with open(args.secure_origin_path, "r") as f: with open(args.secure_origin_path, "r") as f:
args.secure_origin = f.read() args.secure_origin = f.read()
print(f"Secure origin = {args.secure_origin}") print(f"Secure origin = {args.secure_origin}")
print("Check system root CA")
if not os.path.isfile(args.root_ca_path):
origin = api.get_root_ca()
with open(args.root_ca_path, "w") as f:
f.write(origin)
with open(args.root_ca_path, "r") as f:
args.root_ca = f.read()
print(f"Root CA = {args.root_ca}")