private void checkTrusted(X509Certificate[] chain, String authType, String methodSignature) throws CertificateException {
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      Integer key = ourMultiplexor.getKey();
      try (PrintStream out = new PrintStream(os, false, "ISO-8859-1")) {
        out.println(IDE_DELEGATE_TRUST_MANAGER);
        out.println(methodSignature);
        out.println(key);
        out.println(chain.length);
        out.println(authType);

        for (X509Certificate certificate : chain) {
          out.println(BEGIN_CERTIFICATE);

          try {
            out.println(Base64.getMimeEncoder(80, "\n".getBytes(StandardCharsets.US_ASCII))
                          .encodeToString(certificate.getEncoded()));
          }
          catch (CertificateEncodingException e) {
            out.println("#ERROR: " + e.getMessage());
          }
          out.println(END_CERTIFICATE);
        }
        out.println(methodSignature);
        sendAndWaitForResponse(os.toString("ISO-8859-1"), key);
      }
      catch (UnsupportedEncodingException ignore) {
        throw new CertificateException("Unsupported encoding");
      }
    }
private void checkTrusted(X509Certificate[] chain, String authType, String methodSignature)