Your goal is to establish a connection to Snowflake using an RSA PKCS8 private key. However, the behavior of snowflake.connector changes based on how the key is generated. Your challenge is to determine the correct connection parameters for both encrypted and unencrypted private keys.
Step 1: Use OpenSSL to generate two different private keys
Encrypted Private key (Passphrase Required)
openssl genrsa 2048 | openssl pkcs8 -topk8 -v2 des3 -inform PEM -out rsa_key_des3.p8
Unencrypted Private key (No Passphrase)
openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.p8
Step 2: Establish Connection by using snowflake.connector library
Your task is to connect to Snowflake using two different RSA private keys. However, depending on how the key was generated, the connection parameters may need to be adjusted.
- Try connecting with the first key (rsa_key_des3.p8) and include the private_key_file_pwd parameter.
- Try connecting with the second key (rsa_key.p8) but this time, decide whether the private_key_file_pwd should be included or not.
Pay close attention to how Snowflake responds to each connection attempt. If you get an error saying a password was provided but not needed, think about whether the private_key_file_pwd parameter should be there in the first place. But, if the connection fails completely, double-check how the key was generated and whether it requires a passphrase. Try adjusting the private_key_file_pwd parameter by adding or removing it and see what changes.
Thanks to @StefanoGiostra for the topic of this challenge 🙂