public class CaCertificatesUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static Certificate[] |
buildCertChain(Certificate[] partialChain,
Collection<Certificate> caCertificates)
Build a certificate chain from the given partial certificate chain, and a collection of CA certificates
Note: the last certificate in the chain is not necessarily a root CA certificate
|
static Certificate |
findSigningCert(Certificate signedCert,
Collection<Certificate> certificates)
Find signing cert of a given certificate in a collection of certificates.
|
static boolean |
isCertificateAuthority(X509Certificate cert)
Whether the certificate is a CA certificate
|
static boolean |
isSelfSigned(Certificate cert)
checks if the given Certificate is self-signed.
|
static X509Certificate[] |
x509CertificatesFromPem(String pem)
Parse PEM encoded certificates to X509Certificate objects.
|
static X509Certificate[] |
x509CertificatesFromPemFile(Path pemFile)
Parse PEM encoded certificates from a file to X509Certificate objects
|
static X509CRL |
x509CrlFromPem(String pem)
Parse PEM encoded CRL to X509CRL object
|
static String |
x509CrlToPem(X509CRL crl)
Convert X509CRL to PEM format
|
public static X509Certificate[] x509CertificatesFromPem(String pem) throws CertificateException, IOException
pem - PEM encoded certificatesCertificateException - if the certificate cannot be parsedIOException - if an I/O error occurspublic static X509Certificate[] x509CertificatesFromPemFile(Path pemFile) throws CertificateException, IOException
pemFile - Path to the PEM fileCertificateException - if the certificate cannot be parsedIOException - if an I/O error occurspublic static boolean isCertificateAuthority(X509Certificate cert)
cert - X509Certificatepublic static X509CRL x509CrlFromPem(String pem) throws CertificateException, IOException, CRLException
pem - PEM encoded CRLCertificateException - if the CRL cannot be parsedIOException - if an I/O error occursCRLException - if the CRL is invalidpublic static String x509CrlToPem(X509CRL crl) throws CRLException
crl - X509CRL objectCRLException - if the CRL cannot be encodedpublic static boolean isSelfSigned(Certificate cert)
cert - CertificateIllegalArgumentException - if the certificate is nullpublic static Certificate findSigningCert(Certificate signedCert, Collection<Certificate> certificates)
signedCert - certificate to find the signing cert for, must not be nullcertificates - collection of CA certificates which might sign the signedCert, must not be nullIllegalArgumentException - if signedCert is nullIllegalArgumentException - if certificates are nullpublic static Certificate[] buildCertChain(Certificate[] partialChain, Collection<Certificate> caCertificates)
partialChain - partial cert chain must not be null or empty, and the first certificate must be the leaf certcaCertificates - collection of CA certificates must not be nullIllegalArgumentException - if cert is nullIllegalArgumentException - if certificates are null