title: java.security.cert.CertificateParsingException: invalid DER-encoded certificate data
body: <p>I am getting the  below  exception when I am trying to import the certificate to java keystore.</p>
  
  <p>"java.security.cert.CertificateParsingException: invalid DER-encoded certificate data"</p>
  
  <pre><code>FileInputStream fis = new FileInputStream(filename);
  BufferedInputStream bis = new BufferedInputStream(fis);
  
  java.security.cert.CertificateFactory cf = java.security.cert.CertificateFactory
              .getInstance("X.509");
  while (bis.available() &gt; 0) {
      Certificate cert = cf.generateCertificate(bis);
  
      if (cert instanceof X509Certificate) {
              certFx.addCertificate("vel", (X509Certificate) cert, true);
      }
  }
  </code></pre>
  
  <p>any help would be appreciated !.    </p>