public class CertUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
CERT_TYPE_X509 |
static int |
DEFAULT_CERT_EXPIRATION_DAYS |
static String |
DEFAULT_SIGN_ALGORITHM |
static String |
KEY_TYPE_RSA |
| Constructor and Description |
|---|
CertUtils() |
| Modifier and Type | Method and Description |
|---|---|
static KeyStore |
createKeyStore() |
static X509Certificate |
createSignedCertificate(X509Certificate certificate,
X509Certificate issuerCertificate,
PrivateKey issuerPrivateKey,
boolean isIntermediate) |
static CertificateAndKeys |
createSignedCertificateAndKey(String dn,
X509Certificate issuerCertificate,
PrivateKey issuerPrivateKey,
boolean isIntermediate) |
static X509Certificate |
generateX509Certificate(KeyPair pair,
String dn,
int days,
String algorithm)
Create a self-signed X.509 cert
|
static PrivateKey |
getPrivateKey(String filename) |
static PublicKey |
getPublicKey(String filename) |
static KeyStore |
loadKeyStore(File file,
String passwd) |
static X509Certificate |
loadX509Certificate(File file) |
public static final String DEFAULT_SIGN_ALGORITHM
public static final String KEY_TYPE_RSA
public static final String CERT_TYPE_X509
public static final int DEFAULT_CERT_EXPIRATION_DAYS
public static X509Certificate generateX509Certificate(KeyPair pair, String dn, int days, String algorithm) throws GeneralSecurityException, IOException
dn - the X.509 Distinguished Name, eg "CN=Test, L=London, C=GB"days - how many days from now the cert is valid foralgorithm - the signing algorithm, eg "SHA256withRSA"GeneralSecurityExceptionIOExceptionpublic static X509Certificate loadX509Certificate(File file) throws CertificateException, IOException
CertificateExceptionIOExceptionpublic static KeyStore createKeyStore() throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException
public static KeyStore loadKeyStore(File file, String passwd) throws IOException, KeyStoreException, CertificateException, NoSuchAlgorithmException
public static PrivateKey getPrivateKey(String filename) throws Exception
Exceptionpublic static PublicKey getPublicKey(String filename) throws Exception
Exceptionpublic static X509Certificate createSignedCertificate(X509Certificate certificate, X509Certificate issuerCertificate, PrivateKey issuerPrivateKey, boolean isIntermediate) throws Exception
Exceptionpublic static CertificateAndKeys createSignedCertificateAndKey(String dn, X509Certificate issuerCertificate, PrivateKey issuerPrivateKey, boolean isIntermediate) throws Exception
ExceptionCopyright © 2011-2018-2019. All Rights Reserved.