public static CertChain create(String instanceIdentifier,X509Certificate[] chain){
  if (chain.length < 2) {
    throw new CodedException(X_CANNOT_CREATE_CERT_PATH,"Chain must have at least user's certificate " + "and root certificate authority");
  }
  X509Certificate trustAnchor=chain[chain.length - 1];
  List<X509Certificate> additionalCerts=new ArrayList<>();
  if (chain.length > 2) {
    additionalCerts.addAll(Arrays.asList(Arrays.copyOfRange(chain,1,chain.length - 1)));
  }
  try {
    return new CertChain(instanceIdentifier,chain[0],trustAnchor,additionalCerts);
  }
 catch (  Exception ex) {
    throw translateWithPrefix(X_CANNOT_CREATE_CERT_PATH,ex);
  }
}

public static CertChain create ( String instanceIdentifier , X509Certificate [ ] chain ) { if ( chain . length < 2 ) { throw new CodedException ( X_CANNOT_CREATE_CERT_PATH , "Chain must have at least user's certificate " + "and root certificate authority" ) ; } X509Certificate trustAnchor = chain [ chain . length - 1 ] ; List < X509Certificate > additionalCerts = new ArrayList < > ( ) ; if ( chain . length > 2 ) { additionalCerts . addAll ( Arrays . asList ( Arrays . copyOfRange ( chain , 1 , chain . length - 1 ) ) ) ; } try { return new CertChain ( instanceIdentifier , chain [ 0 ] , trustAnchor , additionalCerts ) ; } catch ( Exception ex ) { throw translateWithPrefix ( X_CANNOT_CREATE_CERT_PATH , ex ) ; } }
builds certificate chain form the given array of certificates ( ordered with the user ' s certificate first and the root certificate authority last ) .
