public void checkServerTrusted(final X509Certificate[] chain, String authType, @NotNull CertificateConfirmationParameters parameters)
    throws CertificateException {

    CertificateException lastCertificateException = null;
    for (X509TrustManager trustManager : mySystemManagers) {
      try {
        trustManager.checkServerTrusted(chain, authType);
        return;
      }
      catch (CertificateException e) {
        // Check next or fall-back to custom manager
        lastCertificateException = e;
      }
    }

    // check-then-act sequence
    synchronized (myCustomManager) {
      try {
        myCustomManager.checkServerTrusted(chain, authType);
      }
      catch (CertificateException e) {
        if (myCustomManager.isBroken() || !confirmAndUpdate(chain, parameters)) {
          throw lastCertificateException != null ? lastCertificateException : e;
        }
      }
    }
  }
public void checkServerTrusted(final X509Certificate[] chain, String authType, @NotNull CertificateConfirmationParameters parameters)