Share via


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.

public:
 property bool Encrypt { bool get(); void set(bool value); };
public:
 property Microsoft::Data::SqlClient::SqlConnectionEncryptOption ^ Encrypt { Microsoft::Data::SqlClient::SqlConnectionEncryptOption ^ get(); void set(Microsoft::Data::SqlClient::SqlConnectionEncryptOption ^ value); };
public bool Encrypt { get; set; }
public Microsoft.Data.SqlClient.SqlConnectionEncryptOption Encrypt { get; set; }
member this.Encrypt : bool with get, set
member this.Encrypt : Microsoft.Data.SqlClient.SqlConnectionEncryptOption with get, set
Public Property Encrypt As Boolean
Public Property Encrypt As SqlConnectionEncryptOption

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.

Note

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

Note

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

See also