Package com.unboundid.util.ssl.cert
Class PKCS10CertificateSigningRequest
java.lang.Object
com.unboundid.util.ssl.cert.PKCS10CertificateSigningRequest
- All Implemented Interfaces:
Serializable
@NotMutable
@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class PKCS10CertificateSigningRequest
extends Object
implements Serializable
This class provides support for decoding a PKCS #10 certificate signing
request (aka certification request or CSR) as defined in
RFC 2986. The certificate
signing request is encoded using the ASN.1 Distinguished Encoding Rules
(DER), which is a subset of BER, and is supported by the code in the
com.unboundid.asn1 package. The ASN.1 specification is as follows:
CertificationRequest ::= SEQUENCE {
certificationRequestInfo CertificationRequestInfo,
signatureAlgorithm AlgorithmIdentifier,
signature BIT STRING
}
CertificationRequestInfo ::= SEQUENCE {
version INTEGER { v1(0) } (v1,...),
subject Name,
subjectPKInfo SubjectPublicKeyInfo,
attributes [0] Attributes
}
SubjectPublicKeyInfo ::= SEQUENCE {
algorithm AlgorithmIdentifier,
subjectPublicKey BIT STRING
}
PKInfoAlgorithms ALGORITHM ::= {
... -- add any locally defined algorithms here -- }
Attributes ::= SET OF Attribute
CRIAttributes ATTRIBUTE ::= {
... -- add any locally defined attributes here -- }
Attribute ::= SEQUENCE {
type OBJECT IDENTIFIER,
values SET SIZE(1..MAX)
}
AlgorithmIdentifier ::= SEQUENCE {
algorithm OBJECT IDENTIFIER,
parameters ANY OPTIONAL
}
SignatureAlgorithms ALGORITHM ::= {
... -- add any locally defined algorithms here -- }
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPKCS10CertificateSigningRequest(byte[] encodedRequest) Decodes the contents of the provided byte array as a PKCS #10 certificate signing request. -
Method Summary
Modifier and TypeMethodDescriptiongenerateCertificateSigningRequest(SignatureAlgorithmIdentifier signatureAlgorithm, KeyPair keyPair, DN subjectDN, X509CertificateExtension... extensions) Generates a PKCS #10 certificate signing request with the provided information.Retrieves a decoded representation of the public key, if available.Retrieves the encoded public key as a bit string.Retrieves the list of certificate extensions included in the certificate signing request.byte[]Retrieves the bytes that comprise the encoded representation of this PKCS #10 certificate signing request.Retrieves the certificate signing request public key algorithm name, if available.Retrieves the public key algorithm name if it is available, or the string representation of the public key algorithm OID if not.Retrieves the certificate signing request public key algorithm OID.Retrieves the encoded public key algorithm parameters, if present.Retrieves the encoded request attributes included in the certificate signing request.Retrieves the certificate signing request signature algorithm name, if available.Retrieves the signature algorithm name if it is available, or the string representation of the signature algorithm OID if not.Retrieves the certificate signing request signature algorithm OID.Retrieves the encoded signature algorithm parameters, if present.Retrieves the signature value for the certificate signing request.Retrieves the certificate signing request subject DN.Retrieves the certificate signing request version.toPEM()Retrieves a list of the lines that comprise a PEM representation of this PKCS #10 certificate signing request.Retrieves a multi-line string containing a PEM representation of this PKCS #10 certificate signing request.toString()Retrieves a string representation of the decoded X.509 certificate.voidtoString(StringBuilder buffer) Appends a string representation of the decoded X.509 certificate to the provided buffer.voidVerifies the signature for this certificate signing request.
-
Constructor Details
-
PKCS10CertificateSigningRequest
Decodes the contents of the provided byte array as a PKCS #10 certificate signing request.- Parameters:
encodedRequest- The byte array containing the encoded PKCS #10 certificate signing request. This must not benull.- Throws:
CertException- If the contents of the provided byte array could not be decoded as a valid PKCS #10 certificate signing request.
-
-
Method Details
-
generateCertificateSigningRequest
@NotNull public static PKCS10CertificateSigningRequest generateCertificateSigningRequest(@NotNull SignatureAlgorithmIdentifier signatureAlgorithm, @NotNull KeyPair keyPair, @NotNull DN subjectDN, @Nullable X509CertificateExtension... extensions) throws CertException Generates a PKCS #10 certificate signing request with the provided information.- Parameters:
signatureAlgorithm- The algorithm to use to generate the signature. This must not benull.keyPair- The key pair to use for the certificate signing request. This must not benull.subjectDN- The subject DN for the certificate signing request. This must not benull.extensions- The set of extensions to include in the certificate signing request. This may benullor empty if the request should not include any custom extensions.- Returns:
- The generated PKCS #10 certificate signing request.
- Throws:
CertException- If a problem is encountered while creating the certificate signing request.
-
getPKCS10CertificateSigningRequestBytes
Retrieves the bytes that comprise the encoded representation of this PKCS #10 certificate signing request.- Returns:
- The bytes that comprise the encoded representation of this PKCS #10 certificate signing request.
-
getVersion
Retrieves the certificate signing request version.- Returns:
- The certificate signing request version.
-
getSignatureAlgorithmOID
Retrieves the certificate signing request signature algorithm OID.- Returns:
- The certificate signing request signature algorithm OID.
-
getSignatureAlgorithmName
Retrieves the certificate signing request signature algorithm name, if available.- Returns:
- The certificate signing request signature algorithm name, or
nullif the signature algorithm OID does not correspond to any known algorithm name.
-
getSignatureAlgorithmNameOrOID
Retrieves the signature algorithm name if it is available, or the string representation of the signature algorithm OID if not.- Returns:
- The signature algorithm name or OID.
-
getSignatureAlgorithmParameters
Retrieves the encoded signature algorithm parameters, if present.- Returns:
- The encoded signature algorithm parameters, or
nullif there are no signature algorithm parameters.
-
getSubjectDN
Retrieves the certificate signing request subject DN.- Returns:
- The certificate signing request subject DN.
-
getPublicKeyAlgorithmOID
Retrieves the certificate signing request public key algorithm OID.- Returns:
- The certificate signing request public key algorithm OID.
-
getPublicKeyAlgorithmName
Retrieves the certificate signing request public key algorithm name, if available.- Returns:
- The certificate signing request public key algorithm name, or
nullif the public key algorithm OID does not correspond to any known algorithm name.
-
getPublicKeyAlgorithmNameOrOID
Retrieves the public key algorithm name if it is available, or the string representation of the public key algorithm OID if not.- Returns:
- The signature algorithm name or OID.
-
getPublicKeyAlgorithmParameters
Retrieves the encoded public key algorithm parameters, if present.- Returns:
- The encoded public key algorithm parameters, or
nullif there are no public key algorithm parameters.
-
getEncodedPublicKey
Retrieves the encoded public key as a bit string.- Returns:
- The encoded public key as a bit string.
-
getDecodedPublicKey
Retrieves a decoded representation of the public key, if available.- Returns:
- A decoded representation of the public key, or
nullif the public key could not be decoded.
-
getRequestAttributes
Retrieves the encoded request attributes included in the certificate signing request.- Returns:
- The encoded request attributes included in the certificate signing request.
-
getExtensions
Retrieves the list of certificate extensions included in the certificate signing request.- Returns:
- The list of certificate extensions included in the certificate signing request.
-
getSignatureValue
Retrieves the signature value for the certificate signing request.- Returns:
- The signature value for the certificate signing request.
-
verifySignature
Verifies the signature for this certificate signing request.- Throws:
CertException- If the certificate signing request's signature could not be verified.
-
toString
Retrieves a string representation of the decoded X.509 certificate. -
toString
Appends a string representation of the decoded X.509 certificate to the provided buffer.- Parameters:
buffer- The buffer to which the information should be appended.
-
toPEM
Retrieves a list of the lines that comprise a PEM representation of this PKCS #10 certificate signing request.- Returns:
- A list of the lines that comprise a PEM representation of this PKCS #10 certificate signing request.
-
toPEMString
Retrieves a multi-line string containing a PEM representation of this PKCS #10 certificate signing request.- Returns:
- A multi-line string containing a PEM representation of this PKCS #10 certificate signing request.
-