java.lang.Object
org.shredzone.acme4j.util.CSRBuilder
Generator for a CSR (Certificate Signing Request) suitable for ACME servers.
Requires Bouncy Castle. The BouncyCastleProvider
must also be added as security provider.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a domain name to the CSR.voidaddDomains(String... domains)Adds multiple domain names.voidaddDomains(Collection<String> domains)Adds aCollectionof domains.voidaddIdentifier(Identifier id)Adds anIdentifier.voidaddIdentifiers(Collection<Identifier> ids)Adds aCollectionofIdentifier.voidaddIdentifiers(Identifier... ids)Adds multipleIdentifier.voidaddIP(InetAddress address)Adds anInetAddress.voidaddIPs(InetAddress... ips)Adds multiple IP addresses.voidaddIPs(Collection<InetAddress> ips)Adds aCollectionof IP addresses.org.bouncycastle.pkcs.PKCS10CertificationRequestgetCSR()Gets the PKCS#10 certification request.byte[]Gets an encoded PKCS#10 certification request.voidsetCountry(String c)Sets the country.voidsetLocality(String l)Sets the city or locality.voidSets the organization.voidSets the organizational unit.voidSets the state or province.voidSigns the completed CSR.toString()voidwrite(OutputStream out)Writes the signed certificate request to anOutputStream.voidWrites the signed certificate request to aWriter.
-
Constructor Details
-
CSRBuilder
public CSRBuilder()
-
-
Method Details
-
addDomain
Adds a domain name to the CSR. The first domain name added will also be the Common Name. All domain names will be added as Subject Alternative Name.IDN domain names are ACE encoded automatically.
For wildcard certificates, the domain name must be prefixed with
"*.".- Parameters:
domain- Domain name to add
-
addDomains
Adds aCollectionof domains.IDN domain names are ACE encoded automatically.
- Parameters:
domains- Collection of domain names to add
-
addDomains
Adds multiple domain names.IDN domain names are ACE encoded automatically.
- Parameters:
domains- Domain names to add
-
addIP
Adds anInetAddress. All IP addresses will be set as iPAddress Subject Alternative Name.- Parameters:
address-InetAddressto add- Since:
- 2.4
-
addIPs
Adds aCollectionof IP addresses.- Parameters:
ips- Collection of IP addresses to add- Since:
- 2.4
-
addIPs
Adds multiple IP addresses.- Parameters:
ips- IP addresses to add- Since:
- 2.4
-
addIdentifier
Adds anIdentifier. Only DNS and IP types are supported.- Parameters:
id-Identifierto add- Since:
- 2.7
-
addIdentifiers
Adds aCollectionofIdentifier.- Parameters:
ids- Collection of Identifiers to add- Since:
- 2.7
-
addIdentifiers
Adds multipleIdentifier.- Parameters:
ids- Identifiers to add- Since:
- 2.7
-
setOrganization
Sets the organization.Note that it is at the discretion of the ACME server to accept this parameter.
-
setOrganizationalUnit
Sets the organizational unit.Note that it is at the discretion of the ACME server to accept this parameter.
-
setLocality
Sets the city or locality.Note that it is at the discretion of the ACME server to accept this parameter.
-
setState
Sets the state or province.Note that it is at the discretion of the ACME server to accept this parameter.
-
setCountry
Sets the country.Note that it is at the discretion of the ACME server to accept this parameter.
-
sign
Signs the completed CSR.- Parameters:
keypair-KeyPairto sign the CSR with- Throws:
IOException
-
getCSR
Gets the PKCS#10 certification request. -
getEncoded
Gets an encoded PKCS#10 certification request.- Throws:
IOException
-
write
Writes the signed certificate request to aWriter.- Parameters:
w-Writerto write the PEM file to. TheWriteris closed after use.- Throws:
IOException
-
write
Writes the signed certificate request to anOutputStream.- Parameters:
out-OutputStreamto write the PEM file to. TheOutputStreamis closed after use.- Throws:
IOException
-
toString
-