public class X509CertificateUtil extends Object
| Constructor and Description |
|---|
X509CertificateUtil() |
| Modifier and Type | Method and Description |
|---|---|
static X509Certificate |
generateCertificate(String dn,
KeyPair pair,
int days,
String algorithm)
Create a self-signed X.509 Certificate
|
static boolean |
isSelfSignedCertificate(Certificate certificate)
Tests the X509 certificate to see if it was self-signed.
|
static void |
writeCertificatesToJks(Certificate[] certs,
File file,
String keystorePassword) |
static void |
writeCertificateToFile(Certificate cert,
File file) |
static void |
writeCertificateToJceks(Certificate cert,
File file) |
static void |
writeCertificateToJks(Certificate cert,
File file) |
static void |
writeCertificateToJks(Certificate cert,
File file,
String keystorePassword) |
static void |
writeCertificateToPkcs12(Certificate cert,
File file) |
public static X509Certificate generateCertificate(String dn, KeyPair pair, int days, String algorithm)
dn - the X.509 Distinguished Name, eg "CN=Test, L=London, C=GB"pair - the KeyPairdays - how many days from now the Certificate is valid foralgorithm - the signing algorithm, eg "SHA1withRSA"public static void writeCertificateToFile(Certificate cert, File file) throws CertificateEncodingException, IOException
public static void writeCertificateToJks(Certificate cert, File file) throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException
public static void writeCertificateToJks(Certificate cert, File file, String keystorePassword) throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException
public static void writeCertificatesToJks(Certificate[] certs, File file, String keystorePassword) throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException
public static void writeCertificateToJceks(Certificate cert, File file) throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException
public static void writeCertificateToPkcs12(Certificate cert, File file) throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException
public static boolean isSelfSignedCertificate(Certificate certificate)
The certificate is determined to be self-signed if the subject DN is the same as the issuer DN
certificate - the X509Certificate to testtrue if the X509 certficate is self-signed; otherwise falseCopyright © 2022 The Apache Software Foundation. All rights reserved.