private List < Certificate > convertToBouncyCastleCertificate ( X509Certificate [ ] chain ) { final List < Certificate > bcChain = new ArrayList <> ( ) ; for ( X509Certificate cert : chain ) { try { bcChain . add ( Certificate . getInstance ( cert . getEncoded ( ) ) ) ; } catch ( CertificateEncodingException ex ) { throw new RuntimeException ( "Failed to decode the certificate DER data" ) ; } } return bcChain ; }
Converts X509Certificate to Bouncy Castle Certificate