Package org.cryptomator.cryptolib.common
Class X509CertBuilder
- java.lang.Object
-
- org.cryptomator.cryptolib.common.X509CertBuilder
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description X509Certificate
build()
Creates a self-signed X509Certificate containing the public key and signed with the private key of a given key pair.X509CertBuilder
withIssuer(String issuer)
Sets the certificate's issuerX509CertBuilder
withNotAfter(Instant notAfter)
Sets the certificate's end of validity periodX509CertBuilder
withNotBefore(Instant notBefore)
Sets the certificate's begin of validity periodX509CertBuilder
withSubject(String subject)
Sets the certificate's subject
-
-
-
Method Detail
-
withIssuer
public X509CertBuilder withIssuer(String issuer)
Sets the certificate's issuer- Parameters:
issuer
- DistinguishedName as defined in RFC 4514, e.g.CN=Issuer
- Returns:
this
- See Also:
- RFC 4514, Examples
-
withSubject
public X509CertBuilder withSubject(String subject)
Sets the certificate's subject- Parameters:
subject
- DistinguishedName as defined in RFC 4514, e.g.CN=Subject
- Returns:
this
- See Also:
- RFC 4514, Examples
-
withNotBefore
public X509CertBuilder withNotBefore(Instant notBefore)
Sets the certificate's begin of validity period- Parameters:
notBefore
- date before which the certificate is not valid.- Returns:
this
-
withNotAfter
public X509CertBuilder withNotAfter(Instant notAfter)
Sets the certificate's end of validity period- Parameters:
notAfter
- date after which the certificate is not valid.- Returns:
this
-
build
public X509Certificate build() throws CertificateException, IllegalStateException
Creates a self-signed X509Certificate containing the public key and signed with the private key of a given key pair.- Returns:
- A self-signed X509Certificate
- Throws:
CertificateException
- If certificate generation failed, e.g. due to invalid parametersIllegalStateException
- If one or more required parameters have not been set yet
-
-