static public X509Certificate readCertificate ( String filename ) throws Exception { InputStream inStream = null ; X509Certificate cert = null ; try { inStream = Config . getInstance ( ) . getInputStreamFromFile ( filename ) ; if ( inStream != null ) { CertificateFactory cf = CertificateFactory . getInstance ( "X.509" ) ; cert = ( X509Certificate ) cf . generateCertificate ( inStream ) ; } else { logger . info ( "Certificate " + Encode . forJava ( filename ) + " not found." ) ; } } catch ( Exception e ) { logger . error ( "Exception: " , e ) ; } finally { if ( inStream != null ) { try { inStream . close ( ) ; } catch ( IOException ioe ) { logger . error ( "Exception: " , ioe ) ; } } } return cert ; }
Read certificate from a file and convert it into X509Certificate object