public class CertificateUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
SUBJECT_ALT_NAME_DNS_NAME |
static int |
SUBJECT_ALT_NAME_IP_ADDRESS |
static int |
SUBJECT_ALT_NAME_URI |
| Constructor and Description |
|---|
CertificateUtil() |
| Modifier and Type | Method and Description |
|---|---|
static X509Certificate |
decodeCertificate(byte[] certificateBytes)
Decode a DER-encoded X.509 certificate.
|
static X509Certificate |
decodeCertificate(InputStream inputStream)
Decode a DER-encoded X.509 certificate.
|
static List<X509Certificate> |
decodeCertificates(byte[] certificateBytes)
Decode either a sequence of DER-encoded X.509 certificates or a PKCS#7 certificate chain.
|
static List<X509Certificate> |
decodeCertificates(InputStream inputStream)
Decode either a sequence of DER-encoded X.509 certificates or a PKCS#7 certificate chain.
|
static org.bouncycastle.pkcs.PKCS10CertificationRequest |
generateCsr(KeyPair keyPair,
String subjectName,
String sanUri,
List<String> sanDnsNames,
List<String> sanIpAddresses,
String signatureAlgorithm)
Generate a
PKCS10CertificationRequest. |
static org.bouncycastle.pkcs.PKCS10CertificationRequest |
generateCsr(KeyPair keyPair,
org.bouncycastle.asn1.x500.X500Name subject,
String sanUri,
List<String> sanDnsNames,
List<String> sanIpAddresses,
String signatureAlgorithm)
Generate a
PKCS10CertificationRequest. |
static org.bouncycastle.pkcs.PKCS10CertificationRequest |
generateCsr(KeyPair keyPair,
X509Certificate certificate)
Generate a
PKCS10CertificationRequest for the provided certificate and keyPair. |
static ByteString |
getCertificateChainBytes(List<X509Certificate> certificateChain) |
static String |
getCsrPem(org.bouncycastle.pkcs.PKCS10CertificationRequest csr)
Get a PEM-encoded String containing a PKCS #10 certificate signing request.
|
static List<String> |
getSanDnsNames(X509Certificate certificate)
Get the DNS names from the
certificate's Subject Alternative Name extension, if it's present. |
static List<String> |
getSanIpAddresses(X509Certificate certificate)
Get the IP addresses from the
certificate's Subject Alternative Name extension, if it's present. |
static Optional<String> |
getSanUri(X509Certificate certificate)
Get the URI from the
certificate's Subject Alternative Name extension, if it's present. |
static List<Object> |
getSubjectAltNameField(X509Certificate certificate,
int field)
Extract the value of a given SubjectAltName field from a
X509Certificate. |
static ByteString |
thumbprint(X509Certificate certificate) |
public static final int SUBJECT_ALT_NAME_DNS_NAME
public static final int SUBJECT_ALT_NAME_IP_ADDRESS
public static final int SUBJECT_ALT_NAME_URI
public static X509Certificate decodeCertificate(byte[] certificateBytes) throws UaException
certificateBytes - DER-encoded certificate bytes.X509CertificateUaException - if decoding the certificate fails.public static X509Certificate decodeCertificate(InputStream inputStream) throws UaException
inputStream - InputStream containing DER-encoded certificate bytes.X509CertificateUaException - if decoding the certificate fails.public static List<X509Certificate> decodeCertificates(byte[] certificateBytes) throws UaException
certificateBytes - the byte[] to decode from.List of certificates deocded from certificateBytes.UaException - if decoding fails.public static List<X509Certificate> decodeCertificates(InputStream inputStream) throws UaException
inputStream - the InputStream to decode from.List of certificates decoded from inputStream.UaException - if decoding fails.public static org.bouncycastle.pkcs.PKCS10CertificationRequest generateCsr(KeyPair keyPair, X509Certificate certificate) throws Exception
PKCS10CertificationRequest for the provided certificate and keyPair.keyPair - the KeyPair for certificate.certificate - the X509Certificate to request signing for.PKCS10CertificationRequest.Exception - if creating the signing request fails for any reason.public static org.bouncycastle.pkcs.PKCS10CertificationRequest generateCsr(KeyPair keyPair, String subjectName, String sanUri, List<String> sanDnsNames, List<String> sanIpAddresses, String signatureAlgorithm) throws Exception
PKCS10CertificationRequest.keyPair - the KeyPair containing Public and Private keys.subjectName - the subject name, in RFC 4519 style. (CN=foo,O=bar)sanUri - the URI to request in the SAN.sanDnsNames - the DNS names to request in the SAN.sanIpAddresses - the IP addresses to request in the SAN.signatureAlgorithm - the signature algorithm to use when generating the signature to validate the
certificate.PKCS10CertificationRequest.Exception - if creating the signing request fails for any reason.public static org.bouncycastle.pkcs.PKCS10CertificationRequest generateCsr(KeyPair keyPair, org.bouncycastle.asn1.x500.X500Name subject, String sanUri, List<String> sanDnsNames, List<String> sanIpAddresses, String signatureAlgorithm) throws Exception
PKCS10CertificationRequest.keyPair - the KeyPair containing Public and Private keys.subject - the subject name X500Name.sanUri - the URI to request in the SAN.sanDnsNames - the DNS names to request in the SAN.sanIpAddresses - the IP addresses to request in the SAN.signatureAlgorithm - the signature algorithm to use when generating the signature to validate the
certificate.PKCS10CertificationRequest.Exception - if creating the signing request fails for any reason.public static String getCsrPem(org.bouncycastle.pkcs.PKCS10CertificationRequest csr) throws IOException
csr - the X509Certificate to request signing for.IOException - if creating the signing request fails for any reason.public static List<Object> getSubjectAltNameField(X509Certificate certificate, int field)
X509Certificate.certificate - the certificate.field - the field number.Optional containing the value in the field.SUBJECT_ALT_NAME_IP_ADDRESS,
SUBJECT_ALT_NAME_DNS_NAME,
SUBJECT_ALT_NAME_URIpublic static Optional<String> getSanUri(X509Certificate certificate)
certificate's Subject Alternative Name extension, if it's present.certificate - the certificate to get the URI from.public static List<String> getSanDnsNames(X509Certificate certificate)
certificate's Subject Alternative Name extension, if it's present.certificate - the certificate to get the DNS names from.public static List<String> getSanIpAddresses(X509Certificate certificate)
certificate's Subject Alternative Name extension, if it's present.certificate - the certificate to get the IP addresses from.public static ByteString thumbprint(X509Certificate certificate) throws UaException
UaExceptionpublic static ByteString getCertificateChainBytes(List<X509Certificate> certificateChain) throws UaException
UaExceptionCopyright © 2025. All rights reserved.