fixer-m / snowflake-db-net-client

Snowflake .NET Client
Apache License 2.0
51 stars 14 forks source link

Can't connect due to certiface issue or Fordbidden response #29

Closed myshon closed 1 year ago

myshon commented 1 year ago

Thanks @fixer-m for this repository. It's nice alternative to official driver.

Unfortunetely, I encountered some issues. When I run tests with my account credentials

{
  "connection": {
    "user": "{user}",
    "password": "{pass}",
    "account": "{account}.{region}",
    "region": "{region}",
    "warehouse": "SANDBOX_WH",
    "database": "SANDBOX_DB",
    "schema": "PUBLIC",
    "role": "ACCOUNTADMIN"
  }
}

it throws

The SSL connection could not be established, see inner exception.
  ----> System.Security.Authentication.AuthenticationException : The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch

I found that it's dotnet related issue so I tried to bypass cert validation. Then I receive:

Response status code does not indicate success: 403 (Forbidden).

I tried both on .net 3.1 and also after migration project to net6 lts.

Additional question. I see no reference to such API you're using under the hood i.e /queries/v1/query-request Is this v1 API still valid?

fixer-m commented 1 year ago

@myshon Hi!

"account": "{account}.{region}"

Can you please remove region part from account? It is used along with other pieces to build up host URL like this: {account}.{region}.{cloudtag}.snowflakecomputing.com.

So in your case it will have duplicated "region" part, i.e. incorrect host - and incorrect host leads to this error: The remote certificate is invalid according to the validation procedure.

Is this v1 API still valid?

Yes, this library uses the same API as official driver uses. It is public API, but it doesn't have any documentation or usage guides, so It is not mentioned anywhere.

Thanks!

myshon commented 1 year ago

Thanks it works!

BTW. What do you think about bump lib to net6? I've already done and I can prepare PR for you.

fixer-m commented 1 year ago

Great! Yeah, I was thinking about this too, since net core 3.1 reaching the end of support in just a few days. No worries, I'll make this change soon.