> ## Documentation Index
> Fetch the complete documentation index at: https://www.domo.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Snowflake Key Pair Authentication Connector

## Intro

Snowflake is data warehouse software that makes it easy to bring together all your data and make it available to all of the users and systems that need to analyze it. You can use Domo's Snowflake Using Key Pair Authentication connector to retrieve data from a specified warehouse, database, and database schema by inputting an SQL query. For more information about the Snowflake API, go to [https://docs.snowflake.net/manuals](https://docs.snowflake.net/manuals "https://docs.snowflake.net/manuals").

This version of the Snowflake connector is essentially the same as the standard [Snowflake connector](/docs/s/article/360042931814 "Snowflake Connector") except that it supports using key pair authentication rather than the typical username/password authentication. This authentication method requires a 2048-bit (minimum) RSA key pair. You can generate the public-private key pair using OpenSSL. Steps for generating the key pair are provided below. The public key is assigned to the Snowflake user who will use the Snowflake client.

The Snowflake Using Key Pair Authentication connector is a "Database" connector, meaning it retrieves data from a database using a query. In the Data Center, you can access the connector page for this and other Database connectors by clicking **Database** in the toolbar at the top of the window.

This topic discusses the fields and menus that are specific to the Snowflake Using Key Pair Authentication connector user interface. For general information about adding DataSets, setting update schedules, and editing DataSet information, see [Adding a DataSet Using a Data Connector](/docs/s/article/360042926274 "Adding a DataSet Using a Data Connector").

## Prerequisites

To connect to a Snowflake database and create a DataSet, you must have the following:

* The full name of your account (provided by Snowflake). This is the portion of your Snowflake URL immediately following
  ` https://`.

  Note that your full account name may include additional segments that identify the region and cloud platform where your account is hosted. The following table provides account name examples by cloud platform/region. For each row, it assumes your account name is "xy12345."

  <Frame>
    <img alt="snowflake_account_names.png" src="https://mintcdn.com/domoinc/dOzntoqiN0bwn_aD/images/kb/ka05w00000123Kt-00N5w00000Ri7BU-0EM5w000005vO5S.png?fit=max&auto=format&n=dOzntoqiN0bwn_aD&q=85&s=d01e5196629dfe7e5e50c4ba43d78e0e" width="513" height="578" data-path="images/kb/ka05w00000123Kt-00N5w00000Ri7BU-0EM5w000005vO5S.png" />
  </Frame>

* The username used to connect to your Snowflake host

* Your Snowflake private key

* The passphrase used to encrypt the private key file, if you created an encrypted key

### Configure the Public/Private Key Pair

Follow these steps to configure a public/private key pair.

#### Generate a Private Key

1. Open a terminal window.
2. Generate a private key.

   You can create either an unencrypted or encrypted private key.

   * **For Unencrypted private key, use the following command:**

     ```bash theme={"dark"}
     openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.p8 -nocrypt
     ```

   * **For Encrypted private key, use the following command:**

     ```bash theme={"dark"}
     openssl genrsa 2048 | openssl pkcs8 -topk8 -v2 des3 -inform PEM -out rsa_key.p8
     ```

The commands generate a private key in PEM format:

```
    -----BEGIN ENCRYPTED PRIVATE KEY-----
    MIIE6T...
    -----END ENCRYPTED PRIVATE KEY-----
```

#### Generate a Public Key

Generate the public key from the command line by referencing the private key. This example assumes the private key is encrypted and stored in the file `rsa_key.p8`.

Generate a public key from the private key:

```bash theme={"dark"}
openssl rsa -in rsa_key.p8 -pubout -out rsa_key.pub
```

The command generates the public key in PEM format:

```
    -----BEGIN PUBLIC KEY-----
    MIIBIj...
    -----END PUBLIC KEY-----
```

#### Store the Keys Securely

* Store the private and public key files in a secure local directory.
* Record the file paths for future reference.
* The private key uses the PKCS#8 (Public Key Cryptography Standards) format and is encrypted with the specified passphrase.

#### Assign the Public Key to a Snowflake User

Use the [ALTER USER](https://docs.snowflake.com/en/sql-reference/sql/alter-user) command to assign the public key to the user by setting the RSA\_PUBLIC\_KEY property. For example:

`ALTER USER example_user SET RSA_PUBLIC_KEY='MIIBIjANBgkqh...';`

#### Verify the Public Key Fingerprint

1. Run the following command to retrieve the users public key fingerprint, and then copy the output.

```bash theme={"dark"}
DESC USER example_user
  ->> SELECT SUBSTR(
    (SELECT "value" FROM $1
     WHERE "property" = 'RSA_PUBLIC_KEY_FP'),
    LEN('SHA256:') + 1) AS key;
```

2. Run the following command on the command line and copy the output.

```bash theme={"dark"}
openssl rsa -pubin -in rsa_key.pub -outform DER | openssl dgst -sha256 -binary | openssl enc -base64
```

3. Compare both outputs.
   If the values match, the configuration is correct.

#### Key Rotation

Snowflake supports multiple active keys to allow for uninterrupted rotation. Rotate and replace your public and private keys based on the expiration schedule you follow internally.

Currently, you can use the RSA\_PUBLIC\_KEY and RSA\_PUBLIC\_KEY\_2 parameters for ALTER USER to associate up to 2 public keys with a single user.

To rotate your keys,

1. Complete the steps in Using Key Pair Authentication to...

   * Generate a new private and public key set.
   * Assign the public key to the user. Set the public key value to either
     RSA\_PUBLIC\_KEY or RSA\_PUBLIC\_KEY\_2 (whichever key value is not currently in use).

     For example:

     `alter user jsmith set rsa_public_key_2='JERUEHtcve...';`
2. Update the code to connect to Snowflake. Specify the new private key.

   Snowflake verifies the correct active public key for authentication based on the private key submitted with your connection information.
3. Remove the old public key from the user profile. For example:

   `alter user jsmith unset rsa_public_key;`

## Connecting to your Snowflake account

This section enumerates the options in the **Credentials** and **Details** panes in the Snowflake Using Key Pair Authentication Connector page. The components of the other panes in this page, **Scheduling** and **Name & Describe Your DataSet**, are universal across most connector types and are discussed in greater length in [Adding a DataSet Using a Data Connector](/docs/s/article/360042926274 "Adding a DataSet Using a Data Connector").

### Credentials Pane

This pane contains fields for entering credentials to connect to your Snowflake account. The following table describes what is needed for each field:

<table border="1" cellpadding="1" cellspacing="1" data-aura-rendered-by="33:195;a"><thead><tr><th colspan="1" rowspan="1"><p> Field </p></th><th colspan="1" rowspan="1"><p> Description </p></th></tr></thead><tbody><tr><td colspan="1" rowspan="1"><p> Account Identifier </p></td><td colspan="1" rowspan="1"><p> Enter the account name for your Snowflake account. For information about finding your account name, see <a href="" target="_self" title="Snowflake Connector"> Prerequisites </a>. For US West Region, it should be <b> account\_name </b> and for all other regions, use <b> account\_name.region\_id. </b></p></td></tr><tr><td colspan="1" rowspan="1"><p> Username </p></td><td colspan="1" rowspan="1"><p> Enter the username associated with your Snowflake account. </p></td></tr><tr><td colspan="1" rowspan="1"><p> Private Key </p></td><td colspan="1" rowspan="1"><p> Enter your private key. For more information about generating your private key, see <a href="" target="_self" title="Snowflake Using Key Pair Authentication Connector"> Configuring the public/private key pair </a>. </p></td></tr><tr><td colspan="1" rowspan="1"> Passphrase </td><td colspan="1" rowspan="1"> Enter the passphrase used to encrypt the private key file, if you created an encrypted key. </td></tr><tr><td colspan="1" rowspan="1"> Role </td><td colspan="1" rowspan="1"> Enter your user role. </td></tr></tbody></table>

After you have entered valid Snowflake credentials, you can use the same account in Domo any time you create a Snowflake Using Key Pair Authentication DataSet. You can manage connector accounts in the **Accounts** tab in the Data Center. For more information about this tab, see [Managing User Accounts for Connectors](/docs/s/article/360042926054 "Managing User Accounts for Connectors").

### Details Pane

This pane contains a number of fields and menus for entering your SQL query and specifying the location of the data you want to retrieve.

<table border="1" cellpadding="1" cellspacing="1" data-aura-rendered-by="33:195;a"><thead><tr><th colspan="1" rowspan="1"><p> Parameter </p></th><th colspan="1" rowspan="1"><p> Description </p></th></tr></thead><tbody><tr><td colspan="1" rowspan="1"><p> Query </p></td><td colspan="1" rowspan="1"><p> Enter the SQL query to use to retrieve your data. You can use the <b> Query Helper </b> parameter to help you write a usable SQL query. To use the <b> Query Helper </b>, do the following: </p><ol><li><p> Select your desired warehouse, database, database schema, database table, and table columns in each menu. </p></li><li><p> Copy the SQL statement that appears in the <b> Query Helper </b> field. </p></li><li><p> Paste the copied SQL statement into the <b> Query </b> field. </p></li></ol></td></tr><tr><td colspan="1" rowspan="1"><p> Warehouses </p></td><td colspan="1" rowspan="1"><p> Select the warehouse containing the data you want to retrieve. The list populates with all of the warehouses you have access to based on your credentials. </p></td></tr><tr><td colspan="1" rowspan="1"><p> Databases </p></td><td colspan="1" rowspan="1"><p> Select the database containing the data you want to retrieve. The list populates with all of the databases you have access to based on your credentials. </p></td></tr><tr><td colspan="1" rowspan="1"><p> Database Schema </p></td><td colspan="1" rowspan="1"><p> Select the database schema containing the data you want to retrieve. The list populates with all of the schemas you have access to based on your credentials. </p></td></tr><tr><td colspan="1" rowspan="1"><p> Database Tables (Optional) </p></td><td colspan="1" rowspan="1"><p> Select the database table you want to retrieve. The list populates with all of the tables you have access to based on your credentials. If you do not select a database table, the connector retrieves your entire database schema. </p></td></tr><tr><td colspan="1" rowspan="1"><p> Table Columns (Optional) </p></td><td colspan="1" rowspan="1"><p> Select the table columns you want to retrieve. The list populates with all of the columns you have access to based on your credentials. If you do not select a table column, the connector retrieves your entire selected database table. </p></td></tr><tr><td colspan="1" rowspan="1"><p> Query Helper (Optional) </p></td><td colspan="1" rowspan="1"><p> When you select warehouses, databases, schemas, tables, etc. from the above menus, a usable SQL query is built for you in this field. Copy and paste the SQL statement in this field into the <b> Query </b> field. For more information, see <b> Query </b>, above. </p></td></tr><tr><td colspan="1" rowspan="1"> Fetch Size (Optional) </td><td colspan="1" rowspan="1"> Enter a fetch size for memory performance. If this field is left blank, the default value of 1000 will be used. If the DataSet throws an "Out of memory" error, try decreasing the fetch size. </td></tr><tr><td colspan="1" rowspan="1"><span> Convert Null Values to empty string </span></td><td colspan="1" rowspan="1"><span> Selecting this would change all the null values from the source table in Snowflake to empty strings in Domo </span></td></tr><tr><td colspan="1" rowspan="1"><span> Convert Timezone </span></td><td colspan="1" rowspan="1"><span> Selecting a timezone here tells the connector about the timezone of the source data. The connector converts the Timestamp values from the selected timezone to UTC using this information. </span></td></tr></tbody></table>

### <img src="https://mintcdn.com/domoinc/a0p7G9kQK03i1Qvs/images/kb/ka0Vq000000FV1t-00N5w00000Ri7BU-0EM5w000005vO5s.png?fit=max&auto=format&n=a0p7G9kQK03i1Qvs&q=85&s=411761316f97c8155e4305b4f79509d9" style={{width: 20, height: 20, display: 'inline', verticalAlign: 'start', margin: '0'}} width="458" height="1095" data-path="images/kb/ka0Vq000000FV1t-00N5w00000Ri7BU-0EM5w000005vO5s.png" /> Other Panes

For information about the remaining sections of the connector interface, including how to configure scheduling, retry, and update options, see [Adding a DataSet Using a Data Connector](/docs/s/article/360042926274).

## FAQs

<AccordionGroup>
  <Accordion title="Are there any API limits I should be aware of?">
    This depends on your server configuration.
  </Accordion>

  <Accordion title="How frequently will my data update?">
    As often as needed.
  </Accordion>

  <Accordion title="What should I be aware of while writing a query?">
    Make sure that all the words, table names, and field names are correctly spelled. Refer to the Query Helper field for query help.
  </Accordion>

  <Accordion title="Why can't I connect to my Snowflake database? Do I need to whitelist any IP addresses?">
    Before you can connect to a Snowflake database, you must also whitelist a number of IP addresses on your database server on the port you want to connect to. For the full list of IP addresses, see [Whitelisting IP Addresses for Connectors](/docs/s/article/360043630093 "Whitelisting IP Addresses in Domo").
  </Accordion>

  <Accordion title="Is this a Production-level connector?">
    This connector is designed for small/medium DataSets and proof of concept work for large DataSets.
  </Accordion>

  <Accordion title="Why are the lists of warehouses, databases, schemas, etc. not populating correctly?">
    You only see content that that you have access to based on the user role entered for your account in Snowflake. If you aren't seeing something you are expecting, make sure that role has access to that warehouse, database, table. etc.

    If you do not enter a role in Snowflake, the SYSADMIN role is used by default.
  </Accordion>
</AccordionGroup>
