After tons of search, I didn't find how to make equivalent of following command in Java code :
openssl pkcs12 -cacerts -in /path/to/file.p12 -noout
to get only ca certificates from this p12 or openssl pkcs12 -clcerts -in /path/to/file.p12 -noout to get the certificate
In java, I load file.p12 so all this certificates are stored in the PKCS12 keystore but cannot differentiate which is CA cert and which is simple cert. How to do that ?
(In my p12, I have my certificate and N CA certificate which have signed it : CA 2 has signed the certificate, CA 3 has signed the CA 2 certificates ..., CA N has signed the CA N-1 certificates)
2) Another question in the same way : is there a way to order x509 certificate list to obtain (ca 1, ... ca N), I used :
CertificateFactory certFact = CertificateFactory.getInstance("X.509");
CertPath path = certFact.generateCertPath(myCertifList);
But the list need to be already ordered contrary to what I hoped.
3) Is fullchain certificates order guaranteed ? What if Let's Encrypt for example change its strategy and change way to build chain and fullchain in the way we can't rely on actual cert order ? Thank you very much for help !