security - How to load PKCS7 (.p7b) file in java -


i have pkcs7 file, , want load , extract contents.

i tried these 2 methods:

byte[] bytes = files.readallbytes(paths.get("myfile.p7b")); fileinputstream fi = new fileinputstream(file);  //creating pkcs7 object pkcs7 pkcs7signature = new pkcs7(bytes); 

or this

fileinputstream fis = new fileinputstream(new file("myfile.p7b")); pkcs7 pkcs7signature = new pkcs7(fis); 

but got ioexception: sequence tag error

so how can load .p7b file ?

try this. works other pkcs module not sure 7.

final string keystore_file = "file path"; final string keystore_instance = "pkcs7"; final string keystore_pwd = "password"; final string keystore_alias = "key1";  keystore ks = keystore.getinstance(keystore_instance); ks.load(new fileinputstream(keystore_file), keystore_pwd.tochararray()); key key = ks.getkey(keystore_alias, keystore_pwd.tochararray()); privatekey privkey = (privatekey) key; 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -