code: public void saveCertificateChain(OutputStream out) throws IOException, CertificateEncodingException {
  
          CertificateIOUtil.writeCertificate(out, this.certChain[0]);
  
          for (int i = 1; i < this.certChain.length; i++) {
              // skip the self-signed certificates
              if (this.certChain[i].getSubjectDN().equals(certChain[i].getIssuerDN())) {
                  continue;
              }
              CertificateIOUtil.writeCertificate(out, this.certChain[i]);
          }
          out.flush();
      }
docs: COMMENT Used to be "key cert cert cert ...", which is wrong afaik. must be "cert key cert cert ..."