@Override
  public void checkServerTrusted(X509Certificate[] chain, String authType)
      throws CertificateException {
    try {
      if (defaultTrustManager != null) {
        defaultTrustManager.checkServerTrusted(chain, authType);
      }

    } catch (CertificateException ce) {
      // If the certificate chain couldn't be verified using the default trust manager,
      // try verifying the same with the user-provided root CA
      if (userTrustManager != null) {
        userTrustManager.checkServerTrusted(chain, authType);
      }
    }
  }
@Test
  public void testCustomX509TrustManagerWithRecognizedCertificate() throws CertificateException {
    customTrustManager.checkServerTrusted(
        new X509Certificate[] {recognizedSelfSignedCertificate}, "RSA");
  }