public class Cert extends Object
Certificate. Subclasses of Cert can potentially
represent a certificate chain, however, it should be noted that in this case the majority of the
methods of this class still only affect the 'leaf certificate', such as saving and loading,
unless explicitly mentioned to support chains.
To Create a new certificate See CertificateUtils
| Modifier and Type | Field and Description |
|---|---|
X509Certificate |
certificate |
byte[] |
encodedCertificate |
byte[] |
encodedCertificateThumbprint |
| Constructor and Description |
|---|
Cert(byte[] data)
Create Certificate from encoded data, if the data contains more than one certificate, only the
first one is read.
|
Cert(X509Certificate certificate)
Create Certificate from a X509Certificate certificate.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
static Cert |
fromEncoded(byte[] encodedCertChain)
Create
Cert from encoded data. |
static Cert |
fromx509Certificates(X509Certificate... certChain)
Create
Cert from given one ore more X509Certificate certificates. |
X509Certificate |
getCertificate()
Getter for the field
certificate. |
byte[] |
getEncoded()
getEncoded.
|
byte[] |
getEncodedChain()
If a certificate chain is represented by this object, returns encoded chain with the leaf
certificate appearing first and then each chain element towards root direction.
|
byte[] |
getEncodedThumbprint()
getEncodedThumbprint.
|
int |
getKeySize()
getKeySize.
|
int |
hashCode() |
static Cert |
load(File file)
Load X.509 Certificate from a file
|
static Cert |
load(URL url)
Load X.509 Certificate from an url
|
void |
save(File file)
save.
|
void |
saveToPem(File file)
saveToPem.
|
String |
toString() |
public final X509Certificate certificate
public final byte[] encodedCertificate
public final byte[] encodedCertificateThumbprint
public Cert(byte[] data)
throws ServiceResultException
data - encoded CertificateServiceResultException - if any.public Cert(X509Certificate certificate) throws CertificateEncodingException
certificate - a X509Certificate certificateCertificateEncodingException - if any.public static Cert fromEncoded(byte[] encodedCertChain) throws ServiceResultException
Cert from encoded data. If the data contains more than one certificate, the
'leaf certificate' shall be the first entry and is used to represent Cert. The rest of
the data is not validated, but will be returned by getEncodedChain(). Throws
ServiceResultException if data is not valid.ServiceResultExceptionpublic static Cert fromx509Certificates(X509Certificate... certChain) throws ServiceResultException
Cert from given one ore more X509Certificate certificates. If given more
than one certificate, the 'leaf certificate' shall be the first entry and is used to represent
Cert. All given certificates are used to represent getEncodedChain(). Throws
ServiceResultException if data is not valid.ServiceResultExceptionpublic static Cert load(File file) throws IOException, CertificateException
file - a File object.IOException - if any.CertificateException - In case the certificate is not validpublic static Cert load(URL url) throws IOException, CertificateException
url - a URL object.IOException - if any.CertificateException - In case the certificate is not validpublic X509Certificate getCertificate()
Getter for the field certificate.
X509Certificate object.public byte[] getEncoded()
getEncoded.
public byte[] getEncodedChain()
Cert returns just the same as
getEncoded(), but a subclass can override this method to return a chain.public byte[] getEncodedThumbprint()
getEncodedThumbprint.
public int getKeySize()
getKeySize.
public void save(File file) throws IOException
save.
file - a File object.IOException - if any.public void saveToPem(File file) throws IOException
saveToPem.
file - a File object.IOException - if any.Copyright © 2026. All rights reserved.