XD-DENG commented on issue #4875: [AIRFLOW-4031] Allow for key pair auth in 
snowflake hook
URL: https://github.com/apache/airflow/pull/4875#issuecomment-471251776
 
 
   Thanks @mik-laj . Given the sample code is not that "easy" to find, I will 
have a copy here for future reference.
   
   ```python
   import snowflake.connector
   import os
   from cryptography.hazmat.backends import default_backend
   from cryptography.hazmat.primitives.asymmetric import rsa
   from cryptography.hazmat.primitives.asymmetric import dsa
   from cryptography.hazmat.primitives import serialization
   with open("<path>/rsa_key.p8", "rb") as key:
       p_key= serialization.load_pem_private_key(
           key.read(),
           password=os.environ['PRIVATE_KEY_PASSPHRASE'].encode(),
           backend=default_backend()
       )
   
   pkb = p_key.private_bytes(
       encoding=serialization.Encoding.DER,
       format=serialization.PrivateFormat.PKCS8,
       encryption_algorithm=serialization.NoEncryption())
   
   ctx = snowflake.connector.connect(
       user='<user>',
       account='<account>',
       private_key=pkb)
   
   cs = ctx.cursor()
   ```
   
   Will merge now. There is one test failed (out of 8), which should be due to 
transient error.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to