From 5e49c86de7a6ea4bb8d5fa3919173f2e76d0fd86 Mon Sep 17 00:00:00 2001 From: Wufan Shangguan Date: Wed, 25 May 2022 10:12:45 -0700 Subject: [PATCH] SNOW-591431: Fix ocsp wrong host name test failure (#1010) Fix failed test - testWrongHost. --- .../client/jdbc/ConnectionWithOCSPModeIT.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/test/java/net/snowflake/client/jdbc/ConnectionWithOCSPModeIT.java b/src/test/java/net/snowflake/client/jdbc/ConnectionWithOCSPModeIT.java index f788a2156..29561d16a 100644 --- a/src/test/java/net/snowflake/client/jdbc/ConnectionWithOCSPModeIT.java +++ b/src/test/java/net/snowflake/client/jdbc/ConnectionWithOCSPModeIT.java @@ -4,18 +4,17 @@ package net.snowflake.client.jdbc; import static net.snowflake.client.jdbc.ErrorCode.NETWORK_ERROR; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import static org.junit.Assert.*; import java.net.SocketTimeoutException; import java.security.cert.CertificateExpiredException; import java.sql.DriverManager; import java.sql.SQLException; import java.util.Properties; +import javax.net.ssl.SSLHandshakeException; import javax.net.ssl.SSLPeerUnverifiedException; import net.snowflake.client.ConditionalIgnoreRule; import net.snowflake.client.RunningOnGithubAction; @@ -413,7 +412,15 @@ public void testWrongHost() { fail("should fail"); } catch (SQLException ex) { assertThat(ex, instanceOf(SnowflakeSQLException.class)); - assertThat(getCause(ex), instanceOf(SSLPeerUnverifiedException.class)); + + // The certificates used by badssl.com expired around 05/17/2022, + // https://github.com/chromium/badssl.com/issues/504. After the certificates had been updated, + // the exception seems to be changed from SSLPeerUnverifiedException to SSLHandshakeException. + assertThat( + ex.getCause(), + anyOf( + instanceOf(SSLPeerUnverifiedException.class), + instanceOf(SSLHandshakeException.class))); } } }