question: public void importPKCS8 ( BurpCertificate certificate , String filename ) { setStatus ( "Importing private key..." ) ; FileInputStream fis ; File file = new File ( filename ) ; PrivateKey privateKey ; try { fis = new FileInputStream ( file ) ; DataInputStream dis = new DataInputStream ( fis ) ; byte [ ] keyBytes = new byte [ ( int ) file . length ( ) ] ; dis . readFully ( keyBytes ) ; dis . close ( ) ; PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec ( keyBytes ) ; KeyFactory keyFactory = KeyFactory . getInstance ( "RSA" ) ; privateKey = keyFactory . generatePrivate ( keySpec ) ; certificate . setPrivateKey ( privateKey ) ; setCertificateTree ( ) ; setStatus ( "Private Key imported." ) ; } catch ( IOException | NoSuchAlgorithmException | InvalidKeySpecException e ) { setStatus ( "Error importing private Key. (" + e . getMessage ( ) + ")" ) ; e . printStackTrace ( ) ; } catch ( Exception e ) { setStatus ( "Error (" + e . getMessage ( ) + ")" ) ; } }
target:  Import a private Key in PKCS8 format in DER format.