I wanted to store the public private keys (generated from below commands) into Azure Key Vault.
private-key command: openssl genrsa 2048 | openssl pkcs8 -topk8 -v2 des3 -inform PEM -out rsa_key.p8
private-key command: openssl rsa -in rsa_key.p8 -pubout -out rsa_key.pub
Could you please let me know, If I should be storing it as a 'Secret' or 'Key' ? and how should I retrieve them using the Python SDK ?
I Tried to store them as secrets and retrieve them using the get_secret() method of azure.keyvault.KeyVaultClient but the key is getting printed in single line, where as my original key is spanned across multiple lines. (I can format it by replacing space with new line character but don't want to mess with the keys) Any suggestions on how to retrieve the value the way I stored ?
below is the code I used.
from azure.keyvault import KeyVaultClient, KeyVaultAuthentication
from azure.common.credentials import ServicePrincipalCredentials
def auth_callback(server, resource, scope):
credentials = ServicePrincipalCredentials(
client_id = 'xxx..xxx',
secret = 'yyy..yyy',
tenant = 'zzz..zzz',
resource = "https://vault.azure.net"
)
token = credentials.token
return token['token_type'], token['access_token']
secret_values=[]
secret_keys = ['SNOWFLAKE-TEST-KEY']
client = KeyVaultClient(KeyVaultAuthentication(auth_callback))
secret_bundle = client.get_secret("https://keyvault-xxxxxxx.azure.net/", 'SNOWFLAKE-TEST-KEY','')
rsa_key = secret_bundle.value
print(rsa_key)