我的目标是从pkcs#12文件中读取Java中的MAC迭代值,就像openssl
在外壳中使用以下命令将其打印出来一样:
/home/foo> openssl pkcs12 -info -in myPkcs12.pfx -passin pass:myPassword
MAC Iteration 25000
MAC verified OK
PKCS7 Data
...
答案 0 :(得分:0)
我设法通过Bouncy Castle
(Bouncy Castle + Bouncy Castle Provider)库轻松读取了MAC迭代计数。
final File certFile = ...;
final PKCS12PfxPdu pfx = new PKCS12PfxPdu(Files.readAllBytes(certFile.toPath()));
final Pfx asn1Structure = pfx.toASN1Structure();
final MacData macData = asn1Structure.getMacData();
final BigInteger iterationCount = macData.getIterationCount();