![JAR search and dependency download from the Maven repository](/logo.png)
crypto-formats.com.unbound.common.crypto.PKCS12 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unbound-java-provider Show documentation
Show all versions of unbound-java-provider Show documentation
This is a collection of JAVA libraries that implement Unbound cryptographic classes for JAVA provider, PKCS11 wrapper, cryptoki, and advapi
package com.unbound.common.crypto;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.ProviderException;
import java.security.cert.CertificateException;
public class PKCS12
{
public static KeyStore importDer(byte[] der, String passsword) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException
{
char[] passChars = passsword == null ? null : passsword.toCharArray();
KeyStore ks = KeyStore.getInstance("pkcs12");
ks.load(new ByteArrayInputStream(der), passChars);
return ks;
}
public static KeyStore create()
{
try { return KeyStore.getInstance("pkcs12"); }
catch (KeyStoreException e) { throw new ProviderException(e); }
}
public static byte[] exportDer(KeyStore ks, String passsword)
{
char[] passChars = passsword == null ? null : passsword.toCharArray();
ByteArrayOutputStream bs = new ByteArrayOutputStream();
try { ks.store(bs, passChars); }
catch (Exception e) { throw new ProviderException(e); }
return bs.toByteArray();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy