2

I am trying to do client authentication using ssl certificate. I got the private key ( as string ) from keyvault.

As part of the requirement, i need to convert the private key(generated using openssl command) to DER format for snowflake access.

private_key="MIIEpQIBAAKC .... "  #long string containing private key

pkb=<Above key in DER format> 

ctx = snowflake.connector.connect(
    user='SNOWFLAKE_USER',
    account='ACCOUNT',
    private_key=pkb,
    warehouse="WH",
    database="STG",
    schema="RAW"
    )

cs = ctx.cursor()```

Question: How to convert the private key string to DER format in python.
Catija
  • 359
  • 6
  • 21
SunilS
  • 2,030
  • 5
  • 34
  • 62

1 Answers1

1

Take a look at the python docs, specifically the ssl library should be helpful:

https://docs.python.org/3/library/ssl.html#ssl.PEM_cert_to_DER_cert

iggy12345
  • 1,233
  • 12
  • 31
  • It worked after making a small change to the key. Added "-----BEGIN CERTIFICATE-----" & "-----END CERTIFICATE-----". API expects this to be present in key string – SunilS Sep 18 '19 at 12:45