How to forward client certificates and not receiving error? #2004
Answered
by
Abnormal1654
AlexaCodex
asked this question in
Q&A
-
Expected Behavior / New FeatureOcelot forwards private and public cert added in web request by up stream service to down steam service Actual Behavior / Motivation for New FeatureOcelot throws an error Steps to Reproduce the Problem
{
"DownstreamPathTemplate": "/say/test1.ks/",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "thisisahttpsurl",
"Port": 30986
}
],
"UpstreamPathTemplate": "/test1/",
"UpstreamHttpMethod": [ "Get", "POST" ]
}
Specifications
|
Beta Was this translation helpful? Give feedback.
Answered by
Abnormal1654
May 28, 2020
Replies: 1 comment 1 reply
-
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(); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
raman-m
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is pretty basic, but functional: