Configure HTTPS and TLS settings in the SDK

Updated at:
Copy as MD

The Alibaba Cloud SDK V2.0 for .NET sends all requests over HTTPS and validates TLS certificates by default. This topic describes how to override these defaults at the client level and the individual request level.

Client-level configuration (Config object)

Set the protocol on the Config object at client initialization. The setting applies to all requests sent by that client instance.

Set the request protocol

The SDK uses HTTPS by default. To connect to a legacy endpoint that supports only HTTP, set Protocol to "HTTP" in the Config object.

Important

HTTP transmits request data — including credentials — in clear text. Use HTTP only in trusted, isolated environments.

var config = new AlibabaCloud.OpenApiClient.Models.Config{
    // Override the default HTTPS protocol. Use only for legacy HTTP-only endpoints.
    Protocol = "HTTP",
};

Request-level configuration (RuntimeOptions object)

Pass a RuntimeOptions object to override settings for a single API call without affecting other requests from the same client.

Disable TLS certificate validation

By default, the SDK validates TLS certificates for every HTTPS request. To test behind a proxy that uses a self-signed certificate, disable validation for that specific call by setting IgnoreSSL to true.

Important

Disabling certificate validation exposes your traffic to man-in-the-middle attacks. Use this option only in trusted test environments — never in production.

AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions{
    // Skip TLS certificate validation for this call only. Do not use in production.
    IgnoreSSL = true,
};