Skip to content

Commit 7c408d9

Browse files
committed
ENG-2494 - Connection error using Snowflake Private Key auth (#7294)
1 parent 08a9f3b commit 7c408d9

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Changes can also be flagged with a GitHub label for tracking purposes. The URL o
7575
- Fixed monitor filter state syncing [#7239](https://github.com/ethyca/fides/pull/7239)
7676
- Fixed GPC and automated consent being evaluated after FidesInitialized fires [#7222](https://github.com/ethyca/fides/pull/7222)
7777
- Added FidesLocaleUpdated event to FidesJS to notify when a user changes the language [#7234](https://github.com/ethyca/fides/pull/7234)
78+
- Fixed Snowflake connection failing when using private key authentication without passphrase [#7294](https://github.com/ethyca/fides/pull/7294)
7879

7980
### Removed
8081
- Removed cypress-e2e test suite and associated GitHub workflow [#7193](https://github.com/ethyca/fides/pull/7193)

src/fides/api/service/connectors/snowflake_connector.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,27 @@ def get_connect_args(self) -> Dict[str, Any]:
5454
connect_args: Dict[str, Union[str, bytes]] = {}
5555
if config.private_key:
5656
config.private_key = config.private_key.replace("\\n", "\n")
57-
connect_args["private_key"] = config.private_key
58-
if config.private_key_passphrase:
59-
private_key_encoded = serialization.load_pem_private_key(
60-
config.private_key.encode(),
61-
password=config.private_key_passphrase.encode(), # pylint: disable=no-member
62-
backend=default_backend(),
63-
)
64-
private_key = private_key_encoded.private_bytes(
65-
encoding=serialization.Encoding.DER,
66-
format=serialization.PrivateFormat.PKCS8,
67-
encryption_algorithm=serialization.NoEncryption(),
68-
)
69-
connect_args["private_key"] = private_key
57+
58+
# Determine password (None if no passphrase)
59+
password = (
60+
config.private_key_passphrase.encode()
61+
if config.private_key_passphrase
62+
else None
63+
)
64+
65+
# Load and convert the private key to DER/PKCS8 format
66+
# This is required by Snowflake connector regardless of passphrase
67+
private_key_encoded = serialization.load_pem_private_key(
68+
config.private_key.encode(),
69+
password=password,
70+
backend=default_backend(),
71+
)
72+
private_key = private_key_encoded.private_bytes(
73+
encoding=serialization.Encoding.DER,
74+
format=serialization.PrivateFormat.PKCS8,
75+
encryption_algorithm=serialization.NoEncryption(),
76+
)
77+
connect_args["private_key"] = private_key
7078
return connect_args
7179

7280
def query_config(self, node: ExecutionNode) -> SnowflakeQueryConfig:

0 commit comments

Comments
 (0)