JDBC connection for Snowflake using Key Pair Authentication

Sanjay Sharma
Tera Expert

Hi all,

We are trying to establish JDBC connection to Snowflake using Key Pair Authentication. I have uploaded the Snowflake drivers JAR to Mid Server and configured a data source to build connection string to pass private key and password as per https://docs.snowflake.com/en/user-guide/jdbc-configure.html#using-key-pair-authentication.

However, I am getting following error while loading data into ServiceNow

MID Server reported error: java.sql.SQLException: net.snowflake.client.jdbc.SnowflakeSQLException: Private key provided is invalid or not supported: D:/snowflake/privatekey/rsa_keyP.p8: Cannot retrieve the PKCS8EncodedKeySpec

How can this issue be resolved as our internal security policies to connect Snowflake allow to use only via private that is encrypted?

Thanks!

11 REPLIES 11

Community Alums
Not applicable

Hi @Sanjay Sharma ,

You can refer to the solutions provided here for the error:

https://community.snowflake.com/s/article/Private-key-provided-is-invalid-or-not-supported-rsa-key-p...

https://community.snowflake.com/s/question/0D50Z00009NBjgFSAT/issue-with-snowflake-jdbc-connection-u...

Also, you can refer to this article which discusses about the integration :https://community.servicenow.com/community?id=community_article&sys_id=4f1dc0aadb3670d0457ae6be13961...

Mark my answer correct & Helpful, if Applicable.

Thanks,
Sandeep

Hi Sandeep,

Thanks for your help, I am able to compile and connect as per the Snowflake documentation using command prompt.

javac -cp bcprov-jdk18on-171.jar;bcpkix-jdk18on-171.jar JdbcCon.java
java -cp .;snowflake-jdbc-3.13.19.jar;bcprov-jdk18on-171.jar;bcpkix-jdk18on-171.jar JdbcCon.java

Above step has created the following two class files.

JdbcCon.class
JdbcCon$PrivateKeyReader.class

So far so good, however, how can we use these class files with snowflake JDBC drivers in ServiceNow data source?

Any guidance or direction on what will be the next step would be really helpful?

Regards,
Sanjay

SupriyaWaghmode
Kilo Sage

Hello @Sanjay Sharma  @Community Alums 

 

I am also looking for connection URL with private key and file path and facing the issue. Below format which is I am using

 

 

jdbc❄️//abskf01.eu-central-1.snowflakecomputing.com/?private_key_file=filePath&password=pasowrdstring&warehouse=SKF_CENTRAL_DATASETS_WH&db=PRD_APP_SERVICENOW&schema=TICC&role=SERVICENOW

Hello @SupriyaWaghmode 

 

Were you able to resolve the connection string issue?