SqlConnectionStringBuilder.Encrypt Property

Definition

Gets or sets a SqlConnectionEncryptOption value since version 5.0 or a Boolean value for the earlier versions that indicates whether TLS encryption is required for all data sent between the client and server.

C#
public bool Encrypt { get; set; }
C#
public Microsoft.Data.SqlClient.SqlConnectionEncryptOption Encrypt { get; set; }

Property Value

The value of the Encrypt property.

Remarks

This property corresponds to the "Encrypt" key within the connection string.

When TrustServerCertificate is false and Encrypt is Mandatory, Strict or true, the server name (or IP address) in a server's TLS certificate must exactly match the server name (or IP address) specified in the connection string. Otherwise, the connection attempt will fail. For information about support for certificates whose subject starts with a wildcard character (*), see Enable encrypted connections to the Database Engine.

Nota

Starting from version 4.0, the default value of the property Encrypt is set to true while it is false for earlier versions.

Nota

Starting from version 5.0, the data type is updated to SqlConnectionEncryptOption, and the default value of the Encrypt property is set to Mandatory.

Applies to

Produk Versi
SqlClient .NET Core 1.0, 1.1, 2.0, 2.1, 3.0, 3.1, 4.0, 4.1, 5.0, 5.1, 5.2
SqlClient .NET Framework 1.0, 1.1, 2.0, 2.1, 3.0, 3.1, 4.0, 4.1, 5.0, 5.1, 5.2
SqlClient .NET Standard 1.0, 1.1, 2.0, 2.1, 3.0, 3.1, 4.0, 4.1, 5.0, 5.1, 5.2

See also