Skip to Content
New release 11.5 available 🎉

HTTP Client

Configuring the HTTP transport in Babel Licensing client applications

Babel Licensing supports HTTP as an alternative transport protocol to gRPC. The HTTP transport is useful for platforms or environments where gRPC (HTTP/2) is not available or practical, such as older .NET Framework applications or restricted network environments.

To select the HTTP transport, use the UseHttp() method on the configuration object. If UseHttp() is called, the client will communicate with Babel Licensing Service through its REST API instead of gRPC.

Basic Configuration

To configure the client to use HTTP transport:

BabelLicensing.Configure(config => { config.ServiceUrl = "https://localhost:5005"; config.UseHttp(); });

Calling UseHttp() without parameters uses the default HTTP client settings.

Custom HttpClientHandler

You can pass a configuration callback to UseHttp() to customize the HTTP client options. The callback receives an HttpClientOptions object with the following properties:

  • Handler: Gets or sets the HttpClientHandler used for HTTP requests.
  • Timeout: Gets or sets the TimeSpan for the HTTP client timeout.

SSL/TLS with Self-Signed Certificates

When connecting to a service that uses a self-signed certificate, configure the HttpClientHandler to accept the certificate:

BabelLicensing.Configure(config => { config.ServiceUrl = "https://localhost:5005"; config.UseHttp(http => { http.Handler = new HttpClientHandler() { ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true }; }); });

Client Certificates

To present a client certificate during the SSL/TLS handshake:

BabelLicensing.Configure(config => { config.ServiceUrl = "https://localhost:5005"; var certificate = new X509Certificate2("<cert file>.pfx", "<cert password>"); config.UseHttp(http => { http.Handler = new HttpClientHandler() { ClientCertificates = { certificate }, ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator }; }); });

Custom Timeout

You can specify a custom timeout for HTTP requests:

BabelLicensing.Configure(config => { config.ServiceUrl = "https://localhost:5005"; config.UseHttp(http => { http.Timeout = TimeSpan.FromSeconds(10); http.Handler = new HttpClientHandler() { ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true }; }); });

Proxy Configuration

To route HTTP requests through a proxy:

BabelLicensing.Configure(config => { config.ServiceUrl = "https://localhost:5005"; config.UseHttp(http => { http.Handler = new HttpClientHandler() { Proxy = new WebProxy("http://proxy-server:8080") { UseDefaultCredentials = true } }; }); });

UseHttp vs UseGrpc

The transport protocol is determined by which method you call on the configuration:

  • UseHttp(): Uses the REST API over HTTP/1.1. Compatible with all .NET platforms and network configurations.
  • UseGrpc(): Uses gRPC over HTTP/2. Offers better performance through binary serialization and multiplexing, but requires HTTP/2 support.

If neither method is called, the client defaults to gRPC where supported.

Last updated on