Skip to content

About

.NET wrapper for bogdanfinn/tls-client: HTTP/2 and HTTP/3 client with configurable TLS fingerprints.

Topics

Resources

Stars

6 stars

Watchers

0 watching

Forks

Latest commit

 

History

38 Commits

Folders and files

Repository files navigation

.NET Build and Release NuGet Build AOT

Http.TLS

.NET library for HTTP/2 HTTP/3 requests with TLS fingerprinting support. Based on bogdanfinn/tls-client, it allows you to mimic various browser fingerprints to bypass bot protection.

Installation

dotnet add package Http.TLS

Native Library

Download the appropriate native library for your platform from the bogdanfinn/tls-client releases page.

Initialization:

// Initialize once at application startup, dispose on shutdown
using var context = new NativeClientContext("path/to/native-library");

// For AOT builds, register your JsonSerializerContext for custom types
// context.RegisterContext(AppJsonSerializerContext.Default);

Quick Start

using var context = new NativeClientContext("tls-client-windows-64-<version>.dll");

using var client = new RequestClientBuilder()
    .WithBrowserType(BrowserType.Chrome133)
    .WithTimeout(TimeSpan.FromSeconds(30))
    .Build();

var request = new RequestBuilder()
    .WithUrl("https://httpbin.org/get")
    .Build();

var response = await client.SendAsync(request);
Console.WriteLine($"Status: {response?.Status}");
Console.WriteLine($"Body: {response?.Body}");

RequestClientBuilder

Fluent API for client configuration:

using var client = new RequestClientBuilder()
    .WithBrowserType(BrowserType.Chrome133)
    .WithTimeout(TimeSpan.FromSeconds(30))
    .WithProxy("http://proxy:8080")
    .WithCookieJar(true)
    .WithDebug(true)
    .Build();

Available methods:

  • WithBrowserType() - browser fingerprint selection
  • WithTimeout() - request timeout
  • WithProxy() - proxy configuration
  • WithCookieJar() / WithoutCookieJar() - cookie management
  • WithInsecureSkipVerify() - skip SSL verification
  • ...

RequestClientFactory

Factory for managing multiple named client configurations:

var factory = new RequestClientFactory(o => o.BrowserType = BrowserType.Chrome133);
factory.Register("mobile", o => o.BrowserType = BrowserType.SafariIos17_2);

using var defaultClient = factory.CreateClient();
using var mobileClient = factory.CreateClient("mobile");
using var customClient = factory.CreateClient(o => o.WithProxy("http://proxy:8080"));

RequestBuilder

Fluent API for request creation:

var request = new RequestBuilder()
    .WithUrl("https://api.example.com/data")
    .WithMethod(HttpMethod.Post)
    .WithBody(new { name = "John", age = 30 })
    .WithHeader("Authorization", "Bearer token")
    .WithTimeout(TimeSpan.FromSeconds(30))
    .Build();

Available methods:

  • WithUrl() - request URL
  • WithMethod() - HTTP method
  • WithBody() - request body (string, object, byte[])
  • WithHeader() / WithHeaders() - headers
  • WithCookie() / WithCookies() - cookies
  • ...

Examples

GET Request

var request = new RequestBuilder()
    .WithUrl("https://httpbin.org/get")
    .WithMethod(HttpMethod.Get)
    .Build();

var response = await client.SendAsync(request);

POST with JSON

var request = new RequestBuilder()
    .WithUrl("https://httpbin.org/post")
    .WithMethod(HttpMethod.Post)
    .WithBody(new { name = "John", age = 30 })
    .Build();

var response = await client.SendAsync(request);

Target Frameworks

  • .NET Standard 2.0
  • .NET 5.0, 6.0, 8.0, 9.0, 10.0

License

MIT License | Report an Issue

About

.NET wrapper for bogdanfinn/tls-client: HTTP/2 and HTTP/3 client with configurable TLS fingerprints.

Topics

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages