I have followed this https://matt.kotsenas.com/posts/https-in-service-fabric-web-api, created a service in service fabric. The cert was created from KV. I downloaded certificate from KV. And I'm trying to call from my local mahchine. But I get 403 exception.
var handler = new HttpClientHandler();
var bytes = File.ReadAllBytes(certPath);
var cert = new X509Certificate2(bytes);
handler.ClientCertificates.Add(cert);
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var httpClient = new HttpClient(handler);
var response = httpClient.SendAsync(httpRequestMessage).Result;
Exception: Inner Exception 1: HttpRequestException: An error occurred while sending the request.
Inner Exception 2: WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
Inner Exception 3: AuthenticationException: The remote certificate is invalid according to the validation procedure.
How can make this call?
Enabling HTTPS in an ASP.NET Core service running on Service Fabric.
If you have a certificate
PFXfile, import the certificate into thecertificate store.Adding TLS/SSL certificates in Azure App Service
And configuring TLS mutual authentication for Azure App Service.
For more information, refer to the MS Doc and SO Link.