[Snowflake Connector] RunQueryWithKeyPairAuthFilePath
Question
snowflake-connector
Service icon
Forge component by Rita Tomé
Application Type
Service

Hi,

I am trying to connect to Snowflake using the RunQueryWithKeyPairAuthFilePath  action from the Snowflake forge component Version 1.1.0.

Im getting this error:

There was an error. 

 Message: Could not read private key X:\<filepath>\<key_filename>. \n Error : Org.BouncyCastle.OpenSsl.PemException: problem creating ENCRYPTED private key: Org.BouncyCastle.Crypto.InvalidCipherTextException: pad block corrupted

   at Org.BouncyCastle.Crypto.Paddings.Pkcs7Padding.PadCount(Byte[] input)

   at Org.BouncyCastle.Crypto.Paddings.PaddedBufferedBlockCipher.DoFinal(Byte[] output, Int32 outOff)

   at Org.BouncyCastle.Crypto.BufferedBlockCipher.DoFinal(Byte[] input, Int32 inOff, Int32 inLen)

   at Org.BouncyCastle.Pkcs.PrivateKeyInfoFactory.CreatePrivateKeyInfo(Char[] passPhrase, Boolean wrongPkcs12Zero, EncryptedPrivateKeyInfo encInfo)

   at Org.BouncyCastle.OpenSsl.PemReader.ReadPrivateKey(PemObject pemObject)

   at Org.BouncyCastle.OpenSsl.PemReader.ReadPrivateKey(PemObject pemObject)

   at Snowflake.Data.Core.Authenticator.KeyPairAuthenticator.GenerateJwtToken()

 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.MssRunQueryWithKeyPairAuthFilePath(String ssAccount, String ssDatabase, String ssHost, String ssRole, String ssSchema, String ssUser, String ssWarehouse, String ssPrivateKeyFilepath, String ssPrivateKeyPassword, String ssExtraParametersForConnectionString, String ssQuery, Boolean& ssIsSuccessful, String& ssResultInJSON)

 Error Code: 270052

 Source: Snowflake.Data

 Data: System.Collections.ListDictionaryInternal

 InnerException:


I have placed the key file on the Outsystems frontend server and the snowflake connector is able to find this file. I tested this by changing the filename and then I get a different error:

There was an error. 

 Message: Snowflake Internal Error: Unable to connect. Could not find file 'X:\<filepath>\<incorrect_key_filename> '.

 Stacktrace:    at Snowflake.Data.Client.SnowflakeDbConnection.Open()


This points to an incorrect password and when I googled this "pad block corrupted" this also suggests an incorrect password. However Im sure the password is correct because I have succesfully created an ODBC connection to Snowflake on the Outsystems frontend server using the same key file and the same password I am passing in the RunQueryWithKeyPairAuthFilePath. The password consists only of letters, numbers and an exclemation mark:    AAbbb123! 

So Im a bit lost here. Any help would be greatly appreciated.

regards,

Leon



Hi Leon,

Looking at your issue it seems that you have tried hard to resolve it.

I am not sure about below document but hope so you will get some hints after go through it.

https://community.snowflake.com/s/question/0D50Z00009Urma1SAB/invalid-private-key-error-trying-to-connect-snowflake

Please let me know if it works for you.

Thanks,

Ajit Kurane.

Also I am attaching one file here for snowflake connector settings.

Please check it how the inputs are passed there and make changes accordingly at your side.


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