Using key pair authentication in Snowflake NodeJS

Coding In depth
3 min readMar 9, 2022

In this article, we will discuss how to connect the snowflake NodeJs driver using key pair authentication and key pair rotation. In the previous articles, we have discussed how to create a NodeJS wrapper to connect to the Snowflake NodeJS driver. Here is the link. In this article, we had discussed connecting with user names and passwords. But user names and passwords are not the correct way to connect the Snowflake.

Why use key pair authentication?

  • Passwords are not encrypted and can be easily hacked and can be seen from naked eyes.
  • Key pair authentication is an alternate way to authenticate. In key pair authentication, the private key is an encrypted format.
  • The private key is decrypted using a passphrase. Passphrases can be easily stored in secrets or vaults.
  • The private key can be stored in the secrets of using a file and can be directly read when creating a snowflake connection.

How to leverage Private key in NodeJS

Create Key and Passphrase

Generate the PEM file or store it in the .env file. Below is the private key generated. You can follow Snowflake docs for how to generate one.

--

--

Coding In depth

Writing about Angular, React, JavaScript, Java, C#, NodeJS, AWS, MongoDB, and Redis related articles. Please follow, clap stories to motivate us writing more!