code: 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;
      }
docs: read input stream as HEX-encoded DER-encoded bytes
  
  @param in InputStream to read
  @returns DerValue corresponding to decoded HEX-encoded bytes
  @throws IOException if stream can not be interpreted as RFC1421
  encoded bytes