49
Views
1
Comments
[Snowflake Connector] Snowflake Connector-KeyPairAuth
Question
snowflake-connector
Service icon
Forge asset by Rita Tomé

Hi,

I am trying to connect to Snowflake using the "RunQueryWithKeyPairAuthContent" action from the Snowflake forge component Version 1.1.0. Selected the encrypted P8 file. In the 'Extra Parameters For Connection' input parameter of the action, sent the password like below- 

"private_key_pwd={password}"

but still getting below error. Can anyone help. 
Thanks.

----------------------------------------------
 Message: Could not read private key with value passed in connection string. \n Error : incorrect private key value or private key format: use "\n" for newlines and double the equals sign.
 Stacktrace:    at Snowflake.Data.Core.Authenticator.KeyPairAuthenticator.GenerateJwtToken()
   at Snowflake.Data.Core.Authenticator.KeyPairAuthenticator.Authenticate()
   at Snowflake.Data.Client.SnowflakeDbConnection.Open()
   at OutSystems.NssSnowflakeConnector.CssSnowflakeConnector.RunQuery(String ssQuery, Boolean& ssIsSuccessful, String& ssResultInJSON, SnowflakeDbConnection conn, String connectionString)
   at OutSystems.NssSnowflakeConnector.CssSnowflakeConnector.MssRunQueryWithKeyPairAuthContent(String ssAccount, String ssDatabase, String ssHost, String ssRole, String ssSchema, String ssUser, String ssWarehouse, String ssPrivateKeyContent, String ssExtraParametersForConnectionString, String ssQuery, Boolean& ssIsSuccessful, String& ssResultInJSON)
 Error Code: 270052
 Source: Snowflake.Data
 Data: System.Collections.ListDictionaryInternal 

2021-05-12 16-59-06
Fernando Machado

I ran into the same issue, and what worked for me was to apply a replacement where ENTER becomes "\n", and = becomes == 

This was applied at the .NET extension directly.


Sample code

using System.Text.RegularExpressions

...

Regex.Replace(your_private_key_variable.Replace("=","=="), @"\r\n|\r|\n", "\n")


Some referennces to support:

Known issue (Github)

Connection string instructions (Github)


I hope it helps

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.