public final class CertificateUtil extends Object
Modifier and Type | Method and Description |
---|---|
static File |
createTempKeyStore(String keyStoreName,
char[] keyStorePassword) |
static X509Certificate |
generateCertificate(sun.security.x509.X500Name subject,
sun.security.x509.X500Name issuer,
KeyPair keyPair,
int days,
String algoStr)
Generate a Certificate signed by a CA certificate
|
static X509Certificate |
generateSelfSignedCertificate(sun.security.x509.X500Name issuer,
KeyPair keyPair,
int days,
String algoStr)
Create a self signed certificate
|
static KeyManagerFactory |
loadKeyStore(String keyStoreFile,
String keyStorePasswordStr)
Loads the digital certificate from a keystore file
|
public static X509Certificate generateSelfSignedCertificate(sun.security.x509.X500Name issuer, KeyPair keyPair, int days, String algoStr) throws CertificateException, IOException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException
issuer
- The Issuer (which is the same as the subjectkeyPair
- The asymmetric keyPairdays
- Validity number of daysalgoStr
- AlgorithmCertificateException
- If the info store din the certificate is invalidIOException
- If we can't store some info in the certificateNoSuchAlgorithmException
- If the algorithm does not existSignatureException
- If the certificate cannot be signedNoSuchProviderException
- If we don't have a security providerInvalidKeyException
- If the KeyPair is invalidpublic static X509Certificate generateCertificate(sun.security.x509.X500Name subject, sun.security.x509.X500Name issuer, KeyPair keyPair, int days, String algoStr) throws CertificateException, IOException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException
issuer
- The Issuer (which is the same as the subjectkeyPair
- The asymmetric keyPairdays
- Validity number of daysalgoStr
- AlgorithmCertificateException
- If the info store din the certificate is invalidIOException
- If we can't store some info in the certificateNoSuchAlgorithmException
- If the algorithm does not existSignatureException
- If the certificate cannot be signedNoSuchProviderException
- If we don't have a security providerInvalidKeyException
- If the KeyPair is invalidpublic static KeyManagerFactory loadKeyStore(String keyStoreFile, String keyStorePasswordStr) throws Exception
keyStoreFile
- The KeyStore file to loadkeyStorePasswordStr
- The KeyStore passwordException
- If the KeyStore can't be loadedpublic static File createTempKeyStore(String keyStoreName, char[] keyStorePassword) throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException, InvalidKeyException, NoSuchProviderException, SignatureException
Copyright © 2003–2020 The Apache Software Foundation. All rights reserved.