-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathA2APrivateKeyExample.py
More file actions
30 lines (21 loc) · 1 KB
/
A2APrivateKeyExample.py
File metadata and controls
30 lines (21 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Copyright (c) One Identity LLC. All rights reserved.
# Licensed under the Apache License, Version 2.0.
from pysafeguard import A2AContext, SshKeyFormat
# The appliance host name or IP address
host = ""
# Path to the trusted root CA of the appliance
ca_file = ""
# The API key for private key retrieval via A2A
api_key = ""
# Path to the .pem file for certificate authentication
cert_file = ""
# Path to the corresponding .key file for certificate authentication
key_file = ""
print("Retrieving private key credentials")
with A2AContext(host, cert_file, key_file, verify=ca_file) as ctx:
privatekey_openssh = ctx.retrieve_private_key(api_key, key_format=SshKeyFormat.OPENSSH)
print(f"Private Key (OpenSSH): {privatekey_openssh}")
privatekey_ssh2 = ctx.retrieve_private_key(api_key, key_format=SshKeyFormat.SSH2)
print(f"Private Key (SSH2): {privatekey_ssh2}")
privatekey_putty = ctx.retrieve_private_key(api_key, key_format=SshKeyFormat.PUTTY)
print(f"Private Key (Putty): {privatekey_putty}")