public final class CertUtil extends Object
Constructor and Description |
---|
CertUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
exportCert(Certificate cert,
OutputStream out)
Modified from:
http://www.exampledepot.com/egs/java.security.cert/ExportCert.html
Writes a certificate in base64 format.
|
static void |
exportCRL(X509CRL crl,
OutputStream out)
Writes a CRL in base64 format.
|
static void |
exportPrivateKey(PrivateKey pk,
Certificate[] certs,
OutputStream out)
Writes the private key and all certs in base64 format.
|
static String |
getIssuerValue(X509Certificate cert,
String type)
Get a value out of the issuer distinguished name.
|
static String |
getSubjectValue(X509Certificate cert,
String type)
Get a value out of the subject distinguished name.
|
static boolean |
isRevoked(Certificate cert)
Is the certificate revoked?
This loads the CRLs from disk.
|
static boolean |
isRevoked(CertStore store,
Certificate cert)
Is the certificate revoked?
|
static boolean |
isRevoked(I2PAppContext ctx,
Certificate cert)
Is the certificate revoked?
This loads the CRLs from disk.
|
static X509Certificate |
loadCert(File kd)
Get the certificate from a X.509 certificate file.
|
static List<X509Certificate> |
loadCerts(InputStream in)
Get one or more certificates from an input stream.
|
static X509CRL |
loadCRL(InputStream in)
Load a CRL.
|
static CertStore |
loadCRLs()
Load CRLs from standard locations.
|
static CertStore |
loadCRLs(I2PAppContext ctx)
Load CRLs from standard locations.
|
static PublicKey |
loadKey(File kd)
Get the Java public key from a X.509 certificate file.
|
static PrivateKey |
loadPrivateKey(InputStream in)
Get a single Private Key from an input stream.
|
static void |
main(String[] args) |
static boolean |
saveCert(Certificate cert,
File file)
Write a certificate to a file in base64 format.
|
static boolean |
saveCRL(X509CRL crl,
File file)
Write a CRL to a file in base64 format.
|
public static boolean saveCert(Certificate cert, File file)
public static void exportPrivateKey(PrivateKey pk, Certificate[] certs, OutputStream out) throws IOException, GeneralSecurityException
pk
- non-nullcerts
- certificate chain, null or empty to export pk onlyInvalidKeyException
- if the key does not support encodingCertificateEncodingException
- if a cert does not support encodingIOException
GeneralSecurityException
public static void exportCert(Certificate cert, OutputStream out) throws IOException, CertificateEncodingException
IOException
CertificateEncodingException
public static String getSubjectValue(X509Certificate cert, String type)
type
- e.g. "CN"public static String getIssuerValue(X509Certificate cert, String type)
type
- e.g. "CN"public static PublicKey loadKey(File kd) throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
public static X509Certificate loadCert(File kd) throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
public static PrivateKey loadPrivateKey(InputStream in) throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
public static List<X509Certificate> loadCerts(InputStream in) throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
public static boolean saveCRL(X509CRL crl, File file)
public static void exportCRL(X509CRL crl, OutputStream out) throws IOException, CRLException
CRLException
- if the crl does not support encodingIOException
public static boolean isRevoked(Certificate cert)
public static boolean isRevoked(I2PAppContext ctx, Certificate cert)
public static boolean isRevoked(CertStore store, Certificate cert)
public static CertStore loadCRLs()
public static CertStore loadCRLs(I2PAppContext ctx)
public static X509CRL loadCRL(InputStream in) throws GeneralSecurityException
GeneralSecurityException
public static final void main(String[] args)