Skip to content

How to forward client certificates and not receiving error? #2004

Answered by Abnormal1654
AlexaCodex asked this question in Q&A
Discussion options

You must be logged in to vote

This is pretty basic, but functional:

var pipelineConfiguration = new OcelotPipelineConfiguration
{
    PreErrorResponderMiddleware = async (httpContext, next) =>
    {
        try
        {
            var clientCert = await httpContext.Connection.GetClientCertificateAsync();

            if (clientCert != null)
            {
                httpContext.Request.Headers.Add("X-ARR-ClientCert", Convert.ToBase64String(clientCert.GetRawCertData()));
            }
        }
        catch (Exception e)
        {
            logger.Error(e);
        }
        await next.Invoke();
    }
};
app.UseOcelot(pipelineConfiguration).Wait();

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@raman-m
Comment options

Answer selected by raman-m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Middlewares Ocelot feature: Middleware Injection Configuration Ocelot feature: Configuration
3 participants
Converted from issue

This discussion was converted from issue #1130 on March 23, 2024 10:59.