private byte[] encodePKIPATH() throws CertificateEncodingException {
  ListIterator<X509Certificate> li=certs.listIterator(certs.size());
  try {
    DerOutputStream bytes=new DerOutputStream();
    while (li.hasPrevious()) {
      X509Certificate cert=li.previous();
      if (certs.lastIndexOf(cert) != certs.indexOf(cert)) {
        throw new CertificateEncodingException("Duplicate Certificate");
      }
      byte[] encoded=cert.getEncoded();
      bytes.write(encoded);
    }
    DerOutputStream derout=new DerOutputStream();
    derout.write(DerValue.tag_SequenceOf,bytes);
    return derout.toByteArray();
  }
 catch (  IOException ioe) {
    throw new CertificateEncodingException("IOException encoding " + "PkiPath data: " + ioe,ioe);
  }
}

private byte [ ] encodePKIPATH ( ) throws CertificateEncodingException { ListIterator < X509Certificate > li = certs . listIterator ( certs . size ( ) ) ; try { DerOutputStream bytes = new DerOutputStream ( ) ; while ( li . hasPrevious ( ) ) { X509Certificate cert = li . previous ( ) ; if ( certs . lastIndexOf ( cert ) != certs . indexOf ( cert ) ) { throw new CertificateEncodingException ( "Duplicate Certificate" ) ; } byte [ ] encoded = cert . getEncoded ( ) ; bytes . write ( encoded ) ; } DerOutputStream derout = new DerOutputStream ( ) ; derout . write ( DerValue . tag_SequenceOf , bytes ) ; return derout . toByteArray ( ) ; } catch ( IOException ioe ) { throw new CertificateEncodingException ( "IOException encoding " + "PkiPath data: " + ioe , ioe ) ; } }
encode the certpath using pkipath format .
