How to use Base64-encoded DER format in DBT profiles.yml

72 views Asked by At

I'm trying to configure DBT to connect to Snowflake database using a private key in Base64-encoded DER format. The documentation mentions this format, but I'm not sure how to create the key or include it in the profiles.yml file.

Could someone provide a clear guide on how to achieve this?

1

There are 1 answers

0
Adrien Arcuri On

Here's how to use a Base64-encoded DER format your private key in your DBT profiles.yml.

You should have already generated a private key private_key.pem following this documentation: https://docs.snowflake.com/en/user-guide/key-pair-auth#generate-the-private-key

For unencrypted private key:

openssl pkcs8 -topk8 -v2 des3 -inform PEM -outform DER -in private_key.pem -nocrypt | base64 -w0 > b64_private_key.der

For encrypted private key:

openssl pkcs8 -topk8 -v2 des3 -inform PEM -outform DER -in private_key.pem | base64 -w0 > b64_private_key.der

Copy paste the content of the b64_private_key.der to your dbt profiles.yml:

# profiles.yml

my-snowflake-db:
  target: dev
  outputs:
    dev:
      # ...

      # Keypair config
      private_key: [Paste content of b64_private_key.der file here]
      private_key_passphrase: [passphrase for the private key, if key is encrypted]

      # ...

Do a dbt debug to verify your connection:

You should be able to successfully configure DBT to use a Base64-encoded DER format private key for Snowflake database authentication.