Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snowflake auth with privateKey is not working #363

Open
MarthaScheffler opened this issue Aug 26, 2024 · 0 comments
Open

Snowflake auth with privateKey is not working #363

MarthaScheffler opened this issue Aug 26, 2024 · 0 comments
Labels
area/plugin Plugin-related issue or feature request bug Something isn't working good first issue Great issue for new contributors

Comments

@MarthaScheffler
Copy link

Expected Behavior

When I choose authentication via privateKey, the jdbc plugin can successfully connect to Snowflake.

code example:

id: select_from_snowflake
namespace: dev
description: testing Snowflake jdbc

tasks:
  - id: jdbc_snowflake
    type: io.kestra.plugin.jdbc.snowflake.Query
    url: jdbc:snowflake://xxx-xxx.snowflakecomputing.com
    username: KESTRA_USER
    privateKey: "{{ secret('KESTRA_USER_PRIVATE_KEY')}}"
    role: KESTRA_USER_ROLE
    warehouse: KESTRA_USER_WH
    sql: "SELECT COUNT(id) FROM my_database.my_schema.my_table;"
    fetch: true

Actual Behaviour

getting an error.

2024-08-23 15:57:48.907Invalid parameter value type: java.lang.String, expected type: java.security.PrivateKey.
2024-08-23 15:57:48.907net.snowflake.client.jdbc.SnowflakeSQLLoggedException: Invalid parameter value type: java.lang.String, expected type: java.security.PrivateKey.
 at net.snowflake.client.jdbc.DefaultSFConnectionHandler.initialize(DefaultSFConnectionHandler.java:130)
 at net.snowflake.client.jdbc.DefaultSFConnectionHandler.initializeConnection(DefaultSFConnectionHandler.java:98)
 at net.snowflake.client.jdbc.SnowflakeConnectionV1.initConnectionWithImpl(SnowflakeConnectionV1.java:142)
 at net.snowflake.client.jdbc.SnowflakeConnectionV1.<init>(SnowflakeConnectionV1.java:122)
 at net.snowflake.client.jdbc.SnowflakeDriver.connect(SnowflakeDriver.java:214)
 at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
 at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
 at io.kestra.plugin.jdbc.JdbcConnectionInterface.connection(JdbcConnectionInterface.java:63)
 at io.kestra.plugin.jdbc.AbstractJdbcQuery.run(AbstractJdbcQuery.java:77)
 at io.kestra.plugin.jdbc.snowflake.Query.run(Query.java:22)
 at io.kestra.core.runners.WorkerTaskThread.doRun(WorkerTaskThread.java:76)
 at io.kestra.core.runners.AbstractWorkerThread.run(AbstractWorkerThread.java:57)

Steps To Reproduce

  1. create user with private key on Snowflake (https://docs.snowflake.com/en/user-guide/key-pair-auth) and test on some tool that the private key works for connection
  2. create Kestra flow with jdbc plugin and connect to Snowflake via password (works)
  3. try privateKey option with same Kestra flow (doesn't work, no matter what formatting of the key)

several formattings that I already tried:

- id: jdbc_snowflake
    type: io.kestra.plugin.jdbc.snowflake.Query
    url: jdbc:snowflake://zzzz-zzz.snowflakecomputing.com
    role: KESTRA_USER_ROLE
    warehouse: KESTRA_USER_WH
    sql: "SELECT COUNT(inspection_id) FROM my_database.my_schema.my_table;"
    fetch: true
    username: KESTRA_USER
    password: yyyy

    privateKey: |
      -----BEGIN RSA PRIVATE KEY-----
      MIIEpQIBAAKCAQEAspCKB+IVgZ0Jd2hyBAzlX/nIlu4AlG8EbX7pISoDU3wA78AG
      ...
      W3OLz2iVIIw2j5g9ib2149BmHDXKOW0I+suvVWUTpc7JwfkHdTSFitk=
      -----END RSA PRIVATE KEY-----

    privateKey: |
      MIIEpQIBAAKCAQEAspCKB+IVgZ0Jd2hyBAzlX/nIlu4AlG8EbX7pISoDU3wA78AG
      ...
      W3OLz2iVIIw2j5g9ib2149BmHDXKOW0I+suvVWUTpc7JwfkHdTSFitk=

    privateKey: "-----BEGIN RSA PRIVATE KEY-----MIIEpQIBAAKCAQEAspCKB+IVgZ0Jd2hyBAzlX/nIlu4AlG8EbX7pISoDU3wA78AG...W3OLz2iVIIw2j5g9ib2149BmHDXKOW0I+suvVWUTpc7JwfkHdTSFitk=-----END RSA PRIVATE KEY-----

    privateKey: "MIIEpQIBAAKCAQEAspCKB+IVgZ0Jd2hyBAzlX/nIlu4AlG8EbX7pISoDU3wA78AG...W3OLz2iVIIw2j5g9ib2149BmHDXKOW0I+suvVWUTpc7JwfkHdTSFitk="

    privateKey: MIIEpQIBAAKCAQEAspCKB+IVgZ0Jd2hyBAzlX/nIlu4AlG8EbX7pISoDU3wA78AG...W3OLz2iVIIw2j5g9ib2149BmHDXKOW0I+suvVWUTpc7JwfkHdTSFitk=

    privateKey: "-----BEGIN RSA PRIVATE KEY-----\nMIIEpQIBAAKCAQEAspCKB+IVgZ0Jd2hyBAzlX/nIlu4AlG8EbX7pISoDU3wA78AG\n...\nW3OLz2iVIIw2j5g9ib2149BmHDXKOW0I+suvVWUTpc7JwfkHdTSFitk=\n-----END RSA PRIVATE KEY-----\n"

    privateKey: -----BEGIN RSA PRIVATE KEY-----\nMIIEpQIBAAKCAQEAspCKB+IVgZ0Jd2hyBAzlX/nIlu4AlG8EbX7pISoDU3wA78AG\n......\nW3OLz2iVIIw2j5g9ib2149BmHDXKOW0I+suvVWUTpc7JwfkHdTSFitk=\n-----END RSA PRIVATE KEY-----\n

    privateKey: "MIIEpQIBAAKCAQEAspCKB+IVgZ0Jd2hyBAzlX/nIlu4AlG8EbX7pISoDU3wA78AG\n...\nW3OLz2iVIIw2j5g9ib2149BmHDXKOW0I+suvVWUTpc7JwfkHdTSFitk="

    privateKey: MIIEpQIBAAKCAQEAspCKB+IVgZ0Jd2hyBAzlX/nIlu4AlG8EbX7pISoDU3wA78AG\n...\nW3OLz2iVIIw2j5g9ib2149BmHDXKOW0I+suvVWUTpc7JwfkHdTSFitk=

Environment Information

  • Kestra Version: OSS 0.18.2
  • Plugin version: ? (current)
  • Operating System (OS / Docker / Kubernetes): Kubernetes
  • Java Version (If not docker): -

Example flow

No response

@MarthaScheffler MarthaScheffler added the bug Something isn't working label Aug 26, 2024
@kestrabot kestrabot bot added this to Issues Aug 26, 2024
@github-project-automation github-project-automation bot moved this to Backlog in Issues Aug 26, 2024
@kestra-io kestra-io deleted a comment Aug 26, 2024
@anna-geller anna-geller added the area/plugin Plugin-related issue or feature request label Aug 26, 2024
@tchiotludo tchiotludo added good first issue Great issue for new contributors and removed kind/good-first-issue labels Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/plugin Plugin-related issue or feature request bug Something isn't working good first issue Great issue for new contributors
Projects
Status: Backlog
Development

No branches or pull requests

3 participants