Could not read private key with value passed in connection string

See original GitHub issue

Issue description

After upgrading from version 2.0.13 to 2.0.20, the same C# code we use to pass a private key via the connection string now fails.

Example code

We build the connection string with the below C# code, which works fine with version 2.0.13.

var connectionString = $"account={account};host={snowflakeBaseURL};warehouse={c.ServerName};role={role};db={c.DatabaseName};schema={schema};user={c.UserName};authenticator=snowflake_jwt;private_key={certificate};{certPasswordField}";

Error log

Exception:
Snowflake.Data.Client.SnowflakeDbException: 'Error: 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. SqlState: , VendorCode: 270052, QueryId: '

InnerException:
IOException: base64 data appears to be truncated

Configuration

Driver version: 2.0.20

Issue occurs with: net472, net5.0, net6.0

Server version: 7.2.0

Client OS: Windows 10 Enterprise

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
rdhassecommented, Mar 24, 2023

Hello,

Thanks for the details. After following those details, it seems we no longer have this issue with driver version 2.0.22.

Thanks,

Randall

0reactions
plaistedcommented, Jul 7, 2023

@sfc-gh-spanaite the documentation is not up to date for this, thankfully found this issue

The private key to use for key-pair authentication. Must be used in combination with AUTHENTICATOR=snowflake_jwt.If the private key value includes any equal signs (=), make sure to replace each equal sign with two signs (==) to ensure that the connection string is parsed correctly.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not read private key with value passed in connection ...
ERROR. Snowflake.Data.Client.SnowflakeDbException: "Could not read private key with value passed in connection string. \\n Error : System.
Read more >
Pyspark: Error Connecting to Snowflake using Private Key
Just got a chance to try this out, and I'm getting the following error: JDBC driver not able to connect to Snowflake. Error...
Read more >
Support for Public/Private Key Pair Authentication · Issue ...
I am trying this on Linux now, because the Windows ODBC Driver Manager has issues with the PWD field, according to Snowflake. In...
Read more >
Unable to connect to SQL Server with encryption enabled ...
Going back to .NET 5 and Microsoft.Data.SqlClient 3.0.1 fixes the issue. Even after disabling encryption on the server we still receive the same ......
Read more >
Configure a connection string - Azure Storage
Navigate to Security + networking > Access keys in your storage account's settings to see connection strings for both primary and secondary ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found