nl.nikhef.slcshttps.crypto
Class CSR
java.lang.Object
org.bouncycastle.asn1.ASN1Encodable
org.bouncycastle.asn1.pkcs.CertificationRequest
org.bouncycastle.jce.PKCS10CertificationRequest
nl.nikhef.slcshttps.crypto.CSR
- All Implemented Interfaces:
- DEREncodable
public class CSR
- extends PKCS10CertificationRequest
This class is a holder for a PKCS10 Certificate Signing Request, which also
supplies methods to obtain a SHA1 hash of its DER encoding and a method to
obtain a URL encoded PEM string.
- Version:
- 0.1
- Author:
- Mischa Sallé
Field Summary |
protected static String |
DUMMY_DN
Default subject DN certificate signing requests is "C=X, O=Y, CN=Z". |
Method Summary |
private String |
bytetoString(byte[] bytes)
returns a String representation of the given
byte[] array. |
String |
hash()
Returns the SHA1 hash for the DER encoded CSR. |
String |
pemString()
Returns a PEMstring for the CSR as a URL encoded (UTF-8)
String . |
DUMMY_DN
protected static final String DUMMY_DN
- Default subject DN certificate signing requests is "C=X, O=Y, CN=Z".
- See Also:
- Constant Field Values
CSR
public CSR(String subjectDN,
PublicKey pubKey,
PrivateKey privKey)
throws NoSuchAlgorithmException,
NoSuchProviderException,
InvalidKeyException,
SignatureException
- Constructs a Certificate Signing Request for the given keypair using
specified
subjectDN
. It uses SHA1/RSA as signature algorithm.
- Parameters:
subjectDN
- specifies the subject DN to use for signing request.pubKey
- specifies public key of keypair to use for signing request.privKey
- specifies private key of keypair to use for signing request.
- Throws:
NoSuchAlgorithmException
NoSuchProviderException
InvalidKeyException
SignatureException
CSR
public CSR(PublicKey pubKey,
PrivateKey privKey)
throws NoSuchAlgorithmException,
NoSuchProviderException,
InvalidKeyException,
SignatureException
- Constructs a Certificate Signing Request for the keypair using a default
DUMMY_DN
(="C=X, O=Y, CN=Z").
- Parameters:
pubKey
- specifies public key of keypair to use for signing requestprivKey
- specifies private key of keypair to use for signing request
- Throws:
NoSuchAlgorithmException
NoSuchProviderException
InvalidKeyException
SignatureException
- See Also:
CSR(String, PublicKey, PrivateKey)
pemString
public String pemString()
throws IOException
- Returns a PEMstring for the CSR as a URL encoded (UTF-8)
String
.
- Returns:
- String representing URL encoded PEMstring.
- Throws:
IOException
- if construction of PEMstring fails- See Also:
URLEncoder
,
PEMWriter
hash
public String hash()
throws IOException
- Returns the SHA1 hash for the DER encoded CSR.
- Returns:
- String containing the SHA1 hash for the DER encoding.
- Throws:
IOException
- if construction of hash fails
bytetoString
private String bytetoString(byte[] bytes)
- returns a
String
representation of the given
byte[]
array. In Java 1.5 and higher this can be done using
String.format(java.lang.String, java.lang.Object...)
("%02x",bytes[i])
.
- Parameters:
bytes
- byte[]
array to convert
- Returns:
- String representing the
byte[]
array
nl.nikhef.slcshttps
| Mischa Sallé - msalle(AT)nikhef.nl
|