Table of Contents

Use an existing certificate for a host/subdomain

Fluxzy provides ways to use an existing certificate on a particular host instead of the certificate generated on the fly.

This feature can be achieved by using the UseCertificateAction action.

using Fluxzy;
using Fluxzy.Certificates;
using Fluxzy.Rules.Actions;
using Fluxzy.Rules.Filters;
using Fluxzy.Rules.Filters.RequestFilters;

var fluxzySetting = FluxzySetting.CreateDefault();

var myPkcs12Certificate = Certificate.LoadFromPkcs12("/path/to/mydomain.com.pfx", "password");

fluxzySetting.ConfigureRule()
    .WhenHostMatch("mydomain.com", StringSelectorOperation.EndsWith)
    .Do(new UseCertificateAction(myPkcs12Certificate));

// Create a new proxy instance 
await using var proxy = new Proxy(fluxzySetting);

Console.WriteLine("Press any key to exit");
Console.ReadKey();