private X509Certificate[] getCerts(SSLSessionInfo session) {
        try {
            javax.security.cert.X509Certificate[] javaxCerts = session.getPeerCertificateChain();
            if (javaxCerts == null || javaxCerts.length == 0) {
                return null;
            }
            X509Certificate[] javaCerts = new X509Certificate[javaxCerts.length];
            java.security.cert.CertificateFactory cf = java.security.cert.CertificateFactory.getInstance("X.509");
            for (int i = 0; i < javaxCerts.length; i++) {
                byte[] bytes = javaxCerts[i].getEncoded();
                ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
                javaCerts[i] = (X509Certificate) cf.generateCertificate(stream);
            }

            return javaCerts;
        } catch (Exception e) {
            return null;
        }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        }
private X509Certificate [ ] getCerts ( SSLSessionInfo session ) { try { javax . security . cert . X509Certificate [ ] javaxCerts = session . getPeerCertificateChain ( ) ; if ( javaxCerts == null || javaxCerts . length == 0 ) { return null ; } X509Certificate [ ] javaCerts = new X509Certificate [ javaxCerts . length ] ; java . security . cert . CertificateFactory cf = java . security . cert . CertificateFactory . getInstance ( "X.509" ) ; for ( int i = 0 ; i < javaxCerts . length ; i ++ ) { byte [ ] bytes = javaxCerts [ i ] . getEncoded ( ) ; ByteArrayInputStream stream = new ByteArrayInputStream ( bytes ) ; javaCerts [ i ] = ( X509Certificate ) cf . generateCertificate ( stream ) ; } return javaCerts ; } catch ( Exception e ) { return null ; } }
Return the chain of X509 certificates used to negotiate the SSL Session.
<p>
We convert JSSE's javax.security.cert.X509Certificate[]  to servlet's  java.security.cert.X509Certificate[]

@param session the   javax.net.ssl.SSLSession to use as the source of the cert chain.
@return the chain of java.security.cert.X509Certificates used to
negotiate the SSL connection. <br>
Will be null if the chain is missing or empty.