private DerValue readRFC1421Cert ( InputStream in ) throws IOException { DerValue der = null ; String line = null ; BufferedReader certBufferedReader = new BufferedReader ( new InputStreamReader ( in , "ASCII" ) ) ; try { line = certBufferedReader . readLine ( ) ; } catch ( IOException ioe1 ) { throw new IOException ( "Unable to read InputStream: " + ioe1 . getMessage ( ) ) ; } if ( line . equals ( X509Factory . BEGIN_CERT ) ) { /* stream appears to be hex-encoded bytes */ BASE64Decoder decoder = new BASE64Decoder ( ) ; ByteArrayOutputStream decstream = new ByteArrayOutputStream ( ) ; try { while ( ( line = certBufferedReader . readLine ( ) ) != null ) { if ( line . equals ( X509Factory . END_CERT ) ) { der = new DerValue ( decstream . toByteArray ( ) ) ; break ; } else { decstream . write ( decoder . decodeBuffer ( line ) ) ; } } } catch ( IOException ioe2 ) { throw new IOException ( "Unable to read InputStream: " + ioe2 . getMessage ( ) ) ; } } else { throw new IOException ( "InputStream is not RFC1421 hex-encoded " + "DER bytes" ) ; } return der ; }
read input stream as HEX - encoded DER - encoded bytes