question: private void signCertificateChain ( ) { List < Certificate > cc = new ArrayList < > ( ) ; cc . add ( signCert ) ; List < Certificate > oc = new ArrayList < > ( certs ) ; for ( int k = 0 ; k < oc . size ( ) ; ++ k ) { if ( signCert . equals ( oc . get ( k ) ) ) { oc . remove ( k ) ; -- k ; } } boolean found = true ; while ( found ) { X509Certificate v = ( X509Certificate ) cc . get ( cc . size ( ) - 1 ) ; found = false ; for ( int k = 0 ; k < oc . size ( ) ; ++ k ) { X509Certificate issuer = ( X509Certificate ) oc . get ( k ) ; try { v . verify ( issuer . getPublicKey ( ) , provider ) ; found = true ; cc . add ( oc . get ( k ) ) ; oc . remove ( k ) ; break ; } catch ( Exception ignored ) { } } } signCerts = cc ; }
target:  Helper method that creates the collection of certificates used for the main signature based on the complete list of certificates and the sign certificate.