public BurpCertificate importCertificate(String filename){
  setStatus("Importing certificate...");
  FileInputStream fis;
  try {
    fis=new FileInputStream(filename);
    byte value[]=new byte[fis.available()];
    fis.read(value);
    ByteArrayInputStream bais=new ByteArrayInputStream(value);
    fis.close();
    CertificateFactory certFactory=CertificateFactory.getInstance("X.509");
    X509Certificate x509certificate=(X509Certificate)certFactory.generateCertificate(bais);
    BurpCertificate certificate=new BurpCertificate(x509certificate);
    certificate.setPublicKey(x509certificate.getPublicKey());
    certificate.setSource("Imported");
    burpCertificateStore.addCertificate(certificate);
    setCertificateTree();
    setStatus("Certificate imported.");
    setCertificateDetails(certificate);
    return certificate;
  }
 catch (  IOException|CertificateException e) {
    setStatus("Error reading file. (" + e.getMessage() + ")");
    e.printStackTrace();
  }
catch (  Exception e) {
    setStatus("Error (" + e.getMessage() + ")");
    e.printStackTrace();
  }
  return null;
}

public BurpCertificate importCertificate ( String filename ) { setStatus ( "Importing certificate..." ) ; FileInputStream fis ; try { fis = new FileInputStream ( filename ) ; byte value [ ] = new byte [ fis . available ( ) ] ; fis . read ( value ) ; ByteArrayInputStream bais = new ByteArrayInputStream ( value ) ; fis . close ( ) ; CertificateFactory certFactory = CertificateFactory . getInstance ( "X.509" ) ; X509Certificate x509certificate = ( X509Certificate ) certFactory . generateCertificate ( bais ) ; BurpCertificate certificate = new BurpCertificate ( x509certificate ) ; certificate . setPublicKey ( x509certificate . getPublicKey ( ) ) ; certificate . setSource ( "Imported" ) ; burpCertificateStore . addCertificate ( certificate ) ; setCertificateTree ( ) ; setStatus ( "Certificate imported." ) ; setCertificateDetails ( certificate ) ; return certificate ; } catch ( IOException | CertificateException e ) { setStatus ( "Error reading file. (" + e . getMessage ( ) + ")" ) ; e . printStackTrace ( ) ; } catch ( Exception e ) { setStatus ( "Error (" + e . getMessage ( ) + ")" ) ; e . printStackTrace ( ) ; } return null ; }
read an x . 509v3 certificate from a file .
