Fixes GEN-2198: Snowflake unencrypted key support, connection error on storing bytes (#18927)

This commit is contained in:
Ayush Shah 2024-12-05 07:55:44 +05:30 committed by GitHub
parent e770ba8e0e
commit 81b68682aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -121,7 +121,7 @@ def get_connection(connection: SnowflakeConnection) -> Engine:
)
p_key = serialization.load_pem_private_key(
bytes(connection.privateKey.get_secret_value(), "utf-8"),
password=snowflake_private_key_passphrase.encode(),
password=snowflake_private_key_passphrase.encode() or None,
backend=default_backend(),
)
pkb = p_key.private_bytes(
@ -137,11 +137,16 @@ def get_connection(connection: SnowflakeConnection) -> Engine:
"client_session_keep_alive"
] = connection.clientSessionKeepAlive
return create_generic_db_connection(
engine = create_generic_db_connection(
connection=connection,
get_connection_url_fn=get_connection_url,
get_connection_args_fn=get_connection_args_common,
)
if connection.connectionArguments.root and connection.connectionArguments.root.get(
"private_key"
):
del connection.connectionArguments.root["private_key"]
return engine
def test_connection(