public final class CertificateUtil extends Object
Modifier and Type | Method and Description |
---|---|
static File |
createTempKeyStore(String keyStoreName,
char[] keyStorePassword) |
static X509Certificate |
generateCertificate(X500Principal subject,
X500Principal issuer,
KeyPair keyPair,
int days,
String algoStr)
Generate a Certificate signed by a CA certificate
|
static X509Certificate |
generateSelfSignedCertificate(X500Principal issuer,
KeyPair keyPair,
int days,
String algoStr)
Create a self signed certificate
|
static X509Certificate |
generateX509Certificate(X500Principal subjectDn,
X500Principal issuerDn,
KeyPair keyPair,
long daysValidity,
String sigAlgorithm,
boolean isCa) |
static KeyManagerFactory |
loadKeyStore(String keyStoreFile,
String keyStorePasswordStr)
Loads the digital certificate from a keystore file
|
public static X509Certificate generateX509Certificate(X500Principal subjectDn, X500Principal issuerDn, KeyPair keyPair, long daysValidity, String sigAlgorithm, boolean isCa) throws CertificateException
CertificateException
public static X509Certificate generateSelfSignedCertificate(X500Principal 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(X500Principal subject, X500Principal 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–2023 The Apache Software Foundation. All rights reserved.