Table of Contents

Method WithCertificateTrustRule

Namespace
Neo4j.Driver
Assembly
Neo4j.Driver.dll

WithCertificateTrustRule(CertificateTrustRule, IReadOnlyList<X509Certificate2>)

Sets the rule used to validate the server's TLS certificate.

public ConfigBuilder WithCertificateTrustRule(CertificateTrustRule certificateTrustRule, IReadOnlyList<X509Certificate2> trustedCaCertificates = null)

Parameters

certificateTrustRule CertificateTrustRule

The validation rule. See CertificateTrustRule for options.

trustedCaCertificates IReadOnlyList<X509Certificate2>

The CA certificates to trust. Required when certificateTrustRule is TrustList; must be null for all other rules.

Returns

ConfigBuilder

A ConfigBuilder instance for further configuration options.

Remarks

There are three mutually exclusive ways to configure TLS behaviour — see WithEncryptionLevel(EncryptionLevel) for a full description. This method configures how the driver validates the server certificate and is only meaningful when using the third option: a plain bolt:// or neo4j:// URI with TLS enabled via WithEncryptionLevel(EncryptionLevel).

When using a +s URI scheme, the driver always validates against the system CA store. When using a +ssc URI scheme, the driver accepts any certificate. In both cases this setting is ignored.

Exceptions

ArgumentException

Thrown when trustedCaCertificates is inconsistent with certificateTrustRule.

ArgumentOutOfRangeException

Thrown when certificateTrustRule is not a recognised value.

WithCertificateTrustRule(CertificateTrustRule, IReadOnlyList<string>)

Sets the rule used to validate the server's TLS certificate, with trusted CA certificates loaded from files.

public ConfigBuilder WithCertificateTrustRule(CertificateTrustRule certificateTrustRule, IReadOnlyList<string> trustedCaCertificateFileNames = null)

Parameters

certificateTrustRule CertificateTrustRule

The validation rule. See CertificateTrustRule for options.

trustedCaCertificateFileNames IReadOnlyList<string>

Paths to PEM or DER-encoded CA certificate files to trust. Required when certificateTrustRule is TrustList; must be null for all other rules.

Returns

ConfigBuilder

A ConfigBuilder instance for further configuration options.

Remarks

Convenience wrapper around WithCertificateTrustRule(CertificateTrustRule, IReadOnlyList<X509Certificate2>) that loads certificates from disk. See that overload for full remarks, including the mutually exclusive relationship with +s and +ssc URI schemes.

Exceptions

ArgumentException

Thrown when trustedCaCertificateFileNames is inconsistent with certificateTrustRule.

ArgumentOutOfRangeException

Thrown when certificateTrustRule is not a recognised value.