admin管理员组文章数量:1303412
I meet an issue when trying to use snowflake.connector with an RSA pkcs8 key with passphrase.
When I try this code, with this kind of RSA Key:
openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.p8
import snowflake.connector as sc
private_key_file = 'config/rsa_key.p8'
private_key_file_pwd = input(f"Give to me the passphrase of the key {private_key_file}: ")
conn_params = {
'account': 'SFK_ORG-SRF_ISTANCE',
'user': 'TEST_RSA',
'private_key_file': private_key_file,
'private_key_file_pwd': private_key_file_pwd,
'warehouse': 'MY_WH',
'database': 'MY_DB',
'schema': 'MY_SCHEMA',
'role': 'USER_ROLE'
}
conn = sc.connect(**conn_params)
I get this error:
TypeError: Password was given but private key is not encrypted.
Why?
I meet an issue when trying to use snowflake.connector with an RSA pkcs8 key with passphrase.
When I try this code, with this kind of RSA Key:
openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.p8
import snowflake.connector as sc
private_key_file = 'config/rsa_key.p8'
private_key_file_pwd = input(f"Give to me the passphrase of the key {private_key_file}: ")
conn_params = {
'account': 'SFK_ORG-SRF_ISTANCE',
'user': 'TEST_RSA',
'private_key_file': private_key_file,
'private_key_file_pwd': private_key_file_pwd,
'warehouse': 'MY_WH',
'database': 'MY_DB',
'schema': 'MY_SCHEMA',
'role': 'USER_ROLE'
}
conn = sc.connect(**conn_params)
I get this error:
TypeError: Password was given but private key is not encrypted.
Why?
Share Improve this question edited Feb 4 at 17:25 Yunnosch 26.8k9 gold badges44 silver badges62 bronze badges asked Feb 4 at 16:16 Stefano G.Stefano G. 3095 silver badges15 bronze badges 01 Answer
Reset to default -1The problem is how snowflake.connector uses the key.
If the key is created with the option -v2 des3, es:
openssl genrsa 2048 | openssl pkcs8 -topk8 -v2 des3 -inform PEM -out rsa_key_des3.p8
then snowflake.connector uses the key.
So, using this key the previous code works.
But if I use the key shown above (openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.p8
), the snowflake.connector doesn't require the private_key_file_pwd and the most important thing, DOESN'T WANT the private_key_file_pwd.
So with this key, the code must be in this way:
import snowflake.connector as sc
private_key_file = 'config/rsa_key.p8'
conn_params = {
'account': 'SFK_ORG-SRF_ISTANCE',
'user': 'TEST_RSA',
'private_key_file': private_key_file,
'warehouse': 'MY_WH',
'database': 'MY_DB',
'schema': 'MY_SCHEMA',
'role': 'USER_ROLE'
}
conn = sc.connect(**conn_params)
本文标签: python snowflakeconnector amp rsa privatekeyfile issueStack Overflow
版权声明:本文标题:python snowflake.connector & rsa private_key_file issue - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741753434a2395969.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论