diff --git a/Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs b/Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs index 4deb40c75..c35ad7283 100644 --- a/Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs @@ -591,7 +591,7 @@ public void TestAuthenticationExceptionThrowsExceptionAndNotRetried() using (var conn = new MockSnowflakeDbConnection(mockRestRequester)) { string invalidConnectionString = "host=google.com/404;" - + "connection_timeout=0;account=testFailFast;user=testFailFast;password=testFailFast;disableretry=true;forceretryon404=true"; + + "account=account;user=user;password=password;"; conn.ConnectionString = invalidConnectionString; Assert.AreEqual(conn.State, ConnectionState.Closed); @@ -603,8 +603,10 @@ public void TestAuthenticationExceptionThrowsExceptionAndNotRetried() catch (AggregateException e) { Assert.IsInstanceOf(e.InnerException); +#if NET6_0_OR_GREATER Assert.IsInstanceOf(e.InnerException.InnerException); Assert.IsTrue(e.InnerException.InnerException.Message.Contains("The remote certificate is invalid because of errors in the certificate chain: RevocationStatusUnknown")); +#endif } catch (Exception unexpected) { diff --git a/Snowflake.Data/Core/HttpUtil.cs b/Snowflake.Data/Core/HttpUtil.cs index f11e97fa9..7c1760ac5 100755 --- a/Snowflake.Data/Core/HttpUtil.cs +++ b/Snowflake.Data/Core/HttpUtil.cs @@ -394,6 +394,9 @@ protected override async Task SendAsync(HttpRequestMessage catch (Exception e) { lastException = e; + Exception mostInnerException = e; + while (mostInnerException.InnerException != null) mostInnerException = mostInnerException.InnerException; + if (cancellationToken.IsCancellationRequested) { logger.Debug("SF rest request timeout or explicit cancel called."); @@ -404,7 +407,7 @@ protected override async Task SendAsync(HttpRequestMessage logger.Warn("Http request timeout. Retry the request"); totalRetryTime += (int)httpTimeout.TotalSeconds; } - else if (e is HttpRequestException && e.InnerException is AuthenticationException) + else if (mostInnerException is AuthenticationException) { logger.Error("Non-retryable error encountered: ", e); throw;