use of org.bouncycastle.pkcs.bc.BcPKCS12MacCalculatorBuilderProvider in project vcert-java by Venafi.
the class PEMCollectionTest method toPkcs12.
@Test
void toPkcs12() throws VCertException, IOException, GeneralSecurityException, PKCSException {
String body = readResourceAsString("certificates/certWithKey.pem");
PEMCollection pemCollection = PEMCollection.fromStringPEMCollection(body, ChainOption.ChainOptionIgnore, null, null);
byte[] pkcs12Data = pemCollection.toPkcs12(PKCS12_PASSWORD);
PKCS12PfxPdu pfx = new PKCS12PfxPdu(pkcs12Data);
assertThat(pfx.isMacValid(new BcPKCS12MacCalculatorBuilderProvider(BcDefaultDigestProvider.INSTANCE), PKCS12_PASSWORD.toCharArray())).isTrue();
ContentInfo[] infos = pfx.getContentInfos();
assertThat(infos.length).isEqualTo(1);
assertThat(infos[0].getContentType()).isEqualTo(PKCSObjectIdentifiers.encryptedData);
}
Aggregations