Skip to content

Commit

Permalink
SNOW-799391: Add troubleshooting guide link for ssl exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dprzybysz committed Oct 17, 2024
1 parent d8e90a8 commit dff7a41
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/net/snowflake/client/jdbc/RestRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,14 @@ public static CloseableHttpResponse execute(
// if an SSL issue occurs like an SSLHandshakeException then fail
// immediately and stop retrying the requests

throw new SnowflakeSQLLoggedException(null, ErrorCode.NETWORK_ERROR, ex, ex.getMessage());
String formattedMsg =
ex.getMessage()
+ "\n"
+ "Verify that the hostnames and portnumbers in SYSTEM$ALLOWLIST are added to your firewall's allowed list.\n"
+ "To troubleshoot your connection further, you can refer to this article:\n"
+ "https://docs.snowflake.com/en/user-guide/client-connectivity-troubleshooting/overview";

throw new SnowflakeSQLLoggedException(null, ErrorCode.NETWORK_ERROR, ex, formattedMsg);

} catch (Exception ex) {

Expand Down
22 changes: 22 additions & 0 deletions src/test/java/net/snowflake/client/jdbc/ConnectionLatestIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.core.AnyOf.anyOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand Down Expand Up @@ -49,6 +50,7 @@
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLHandshakeException;
import net.snowflake.client.ConditionalIgnoreRule;
import net.snowflake.client.RunningNotOnAWS;
import net.snowflake.client.RunningOnGithubAction;
Expand Down Expand Up @@ -1618,4 +1620,24 @@ public void shouldGetOverridenConnectionAndSocketTimeouts() throws Exception {
assertEquals(Duration.ofMillis(200), HttpUtil.getSocketTimeout());
}
}

/** Added in > 3.19.0 */
@Test
public void shouldFailOnSslExceptionWithLinkToTroubleShootingGuide() {
Properties properties = new Properties();
properties.put("user", "fakeuser");
properties.put("password", "testpassword");
properties.put("ocspFailOpen", Boolean.FALSE.toString());

try {
DriverManager.getConnection("jdbc:snowflake://expired.badssl.com/", properties);
fail("should fail");
} catch (SQLException e) {
assertThat(e.getCause(), instanceOf(SSLHandshakeException.class));
assertTrue(
e.getMessage()
.contains(
"https://docs.snowflake.com/en/user-guide/client-connectivity-troubleshooting/overview"));
}
}
}

0 comments on commit dff7a41

Please sign in to comment.