Method WithCertificateTrustRule
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
certificateTrustRuleCertificateTrustRuleThe validation rule. See CertificateTrustRule for options.
trustedCaCertificatesIReadOnlyList<X509Certificate2>The CA certificates to trust. Required when
certificateTrustRuleis TrustList; must benullfor 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
trustedCaCertificatesis inconsistent withcertificateTrustRule.- ArgumentOutOfRangeException
Thrown when
certificateTrustRuleis 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
certificateTrustRuleCertificateTrustRuleThe validation rule. See CertificateTrustRule for options.
trustedCaCertificateFileNamesIReadOnlyList<string>Paths to PEM or DER-encoded CA certificate files to trust. Required when
certificateTrustRuleis TrustList; must benullfor 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
trustedCaCertificateFileNamesis inconsistent withcertificateTrustRule.- ArgumentOutOfRangeException
Thrown when
certificateTrustRuleis not a recognised value.