Class TestClientCertificateBuilder

Namespace
XBullet.EasyTesting.Authentication
Assembly
XBullet.EasyTesting.dll

Fluently creates a self-signed client certificate for TestServer.

public sealed class TestClientCertificateBuilder
Inheritance
TestClientCertificateBuilder
Inherited Members

Remarks

This mutable builder is not thread-safe. Its default subject is CN=XBullet.EasyTesting Client; its default validity begins one minute before builder creation and ends one hour after builder creation.

Methods

Build()

Creates the client certificate.

public X509Certificate2 Build()

Returns

X509Certificate2

A new self-signed certificate with a 2048-bit RSA private key, SHA-256 signature, digital signature key usage, and client-authentication enhanced key usage. The caller owns and must dispose the certificate.

ValidFrom(DateTimeOffset, DateTimeOffset)

Sets the certificate validity window.

public TestClientCertificateBuilder ValidFrom(DateTimeOffset notBefore, DateTimeOffset notAfter)

Parameters

notBefore DateTimeOffset

The absolute instant at which the certificate becomes valid.

notAfter DateTimeOffset

The absolute instant at which the certificate expires. It must be later than notBefore.

Returns

TestClientCertificateBuilder

This builder so additional certificate values can be configured.

Exceptions

ArgumentOutOfRangeException

notAfter is not later than notBefore.

WithSubject(string)

Sets the certificate subject distinguished name.

public TestClientCertificateBuilder WithSubject(string subject)

Parameters

subject string

The non-empty X.500 distinguished name parsed when Build() runs, for example CN=integration-client.

Returns

TestClientCertificateBuilder

This builder so additional certificate values can be configured.