Skip to content

Latest commit

 

History

History
62 lines (41 loc) · 4.1 KB

readme.md

File metadata and controls

62 lines (41 loc) · 4.1 KB

TlsClient.NET

TlsClient.NET lets you control the TLS handshake and HTTP settings of outbound requests from C#. It wraps bogdanfinn/tls-client and exposes browser profiles, header ordering, proxy settings, and cookies.

Use it to test how a server responds to a particular browser TLS profile or header order, or when your application needs to control these settings for outbound requests.

Choose a transport

Package Where requests run Use it when
TlsClient.Native Inside your .NET process You can ship a native library for your target OS and architecture and want a single application to deploy.
TlsClient.Api In a separate tls-client-api service You already run the service or want to deploy the TLS engine separately from your .NET app.

Both packages use the same Request, Response, and TlsClientBuilder types. NuGet resolves TlsClient.Core as a dependency.

What you can configure

  • Choose a built-in Chrome, Firefox, or Safari TLS profile, or supply a custom TLS profile.
  • Set the User-Agent and request header order, or specify the headers and their order for a proxy CONNECT request.
  • Configure timeouts, redirects, proxies, and per-client cookie sessions.

Use your existing HTTP client

Both transports work with TlsClient.Provider.HttpClient, which supplies a handler for HttpClient, and TlsClient.Provider.RestSharp, which supplies a builder for RestClient.

Usage examples

After setting up either transport, build requests with the same C# API. This example sends a cookie and prints the cookies echoed by the server.

using System;
using TlsClient.Core.Builders;
using TlsClient.Core.Models.Entities;

var request = new RequestBuilder()
    .WithUrl("https://httpbin.io/cookies")
    .WithCookies(new() { new TlsClientCookie("theme", "dark") { Expires = null } })
    .Build();

var cookiesEcho = await client.RequestAsync(request);
Console.WriteLine(cookiesEcho.Body);
I want to Examples
Send cookies or reuse a cookie session Native · API
Send JSON, a form, or a file JSON · Form · Multipart upload
Control outbound header order Request headers · Proxy CONNECT headers
Set a timeout or save a response to disk Response header timeout · File download

The JSON, form, multipart, and request-header examples use types shared by both transports.

Console examples and tests

  • Console examples for Native and API.
  • Integration tests for Native and API. For both native test projects, set TLS_CLIENT_TEST_LIBRARY to the full path of the tls-client v1.18.1 shared library for your platform. Most API integration tests use port 8080. The API body and cookie tests use port 5666. Configure both test endpoints with my-auth-key-1.

Support and license

Report .NET wrapper and packaging issues in TlsClient.NET Issues and engine issues in tls-client Issues.

TlsClient.NET is maintained by Eren Kurt and distributed under the MIT License.