@Test
  @Ignore("HIVE-22621: test case is unstable")
  public void testMetastoreConnectionWrongCertCN() throws Exception {
    SSLTestUtils.setMetastoreSslConf(conf);
    conf.setVar(ConfVars.HIVE_METASTORE_SSL_KEYSTORE_PATH,
        dataFileDir + File.separator +  EXAMPLEDOTCOM_KEY_STORE_NAME);
    miniHS2 = new MiniHS2.Builder().withRemoteMetastore().withConf(conf).cleanupLocalDirOnStartup(false).build();
    try {
      miniHS2.start(confOverlay);
    } catch (java.net.ConnectException e) {
      assertTrue(e.toString().contains("Connection refused"));
    }

    miniHS2.stop();
  }
Verify the HS2 can't connect to HMS if the certificate doesn't match
@throws Exception
itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestSSL.java