Skip to main content
All docs
V25.1
  • MsSqlConnectionParameters.TrustServerCertificate Property

    Gets or sets a value that indicates whether the channel will be encrypted when certificate chain bypass is performed to validate trust.

    Namespace: DevExpress.DataAccess.ConnectionParameters

    Assembly: DevExpress.DataAccess.v25.1.dll

    NuGet Package: DevExpress.DataAccess

    Declaration

    [DefaultValue(DefaultBoolean.Default)]
    public DefaultBoolean TrustServerCertificate { get; set; }

    Property Value

    Type Default Description
    DefaultBoolean Default

    A DefaultBoolean enumeration value that specifies whether the channel will be encrypted when certificate chain bypass is performed to validate trust.

    Available values:

    Name Description Return Value
    True

    The value is true.

    0

    False

    The value is false.

    1

    Default

    The value is specified by a global option or a higher-level object.

    2

    Remarks

    This property corresponds to the “TrustServerCertificate” key within the connection string. When you set TrustServerCertificate to true, the transport layer uses SSL to encrypt the channel and bypass walking the certificate chain to validate trust.

    If the property value is Default, the connection uses the option set by the provider (Microsoft.Data.SqlClient or System.Data.SqlClient).

    The following code snippet shows how to configure connection parameters to establish connection to Microsoft SQL Server:

    using DevExpress.DataAccess.ConnectionParameters;
    using DevExpress.DataAccess.Sql;
    // ...
    MsSqlConnectionParameters connectionParameters = new MsSqlConnectionParameters(){
        ServerName = "localhost",
        DatabaseName = "Northwind",
        AuthorizationType = MsSqlAuthorizationType.Windows,
        TrustServerCertificate = DevExpress.Utils.DefaultBoolean.True,
        Encrypt = DevExpress.Utils.DefaultBoolean.True
    };
    SqlDataSource ds = new SqlDataSource();
    ds.ConnectionName = "nwindConnection";
    ds.ConnectionParameters = connectionParameters;
    

    The resulting connection string looks as follow:

    "XpoProvider=MSSqlServer;data source=localhost;integrated security=SSPI;initial catalog=Northwind;Encrypt=true;TrustServerCertificate=true"

    See Also