deadmann / AdvancedRestHandler

A utility code that can be used to request Data from services...
MIT License
5 stars 0 forks source link

SecurityProtocolType #46

Closed mehrdadkiani20 closed 2 months ago

mehrdadkiani20 commented 2 months ago

ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;

 client.Timeout = new TimeSpan(0, 0, 5, 0, 0);
deadmann commented 2 months ago

Allow globally and locally set TLS version of the internal HttpClient

deadmann commented 2 months ago

@mehrdadkiani20:

Usage:

Global:

AdvancedRestHandler arh = new AdvancedRestHandler(string.Empty, new RestHandlerInitializerOptions
{
    SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13,
    Timeout = TimeSpan.FromSeconds(30)
});

Per Request:

var res = await arh.PostDataAsync<ArhResponse<ApiRes>, ApiReq>(
    "/url-part/123", 
    new ApiReq(),
    new RestHandlerRequestOptions
    {
        SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13,
        Timeout = TimeSpan.FromSeconds(30)
    });