Search code examples
asp.net-coreazure-service-fabricidentityserver4

HTTPS communication in ServiceFabric Local Cluster


Here's my setup

an IdentityServer 4 as a stateless reliable ASP.NET Core service. a WebAPI as a reliable ASP.NET Core service.

using them with a JS client, it is now working with HTTP. The problem is with HTTPS. The WebAPI needs to request the openID config via htttps [is4URL].well-known/openid-configuration. I'm getting this error

System.InvalidOperationException: IDX10803: Unable to obtain configuration from: 'https://localhost:9999/.well-known/openid-configuration'. ---> System.IO.IOException: IDX10804: Unable to retrieve document from: 'https://localhost:9999/.well-known/openid-configuration'. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.

can anybody help me to make this work in localhost with the SF Local Cluster Manager?

Thanks


Solution

  • Here's my two cents worth but it will need to be verified...

    I am assuming that you have created a self-signed certificate using following article or similar but the certificate has same properties.

    https://learn.microsoft.com/en-us/azure/app-service-web/web-sites-configure-ssl-certificate

    This means that the certificate can not be verified via actual CA. Ofcourse with self-signed certificate this is not possible.

    Now when you upload the certificate to Azure App Service it installs in CurrentUser - MyStore. With self-signed certificate, it also needs to be installed in LocalMachine Root store.

    This is becouse then the machine's Certificate Authority can verify that certificate to be valid. (May be a security expert can correct me if I am wrong but thats my theory). I have got same setup on my locally hosted windows server where the self-signed certificate is installed in Root Certificate Store as well as Personal store and the app works. This is the reason I belive this happens.

    So this part which needs to be verified. Following is the article which shows you how you can do this in Azure App service.

    https://learn.microsoft.com/en-us/azure/cloud-services/cloud-services-configure-ssl-certificate-portal

    AGAIN THIS IS JUST A THEORY THIS NEEDS TO BE VERIFIED. :)

    EDIT:

    I have just tested this and it is the case. In cloud services you can do as shown in second link above and create Web Job which install certificate in appropriate store.

    For Azure App Service unfortunaltly you dont have access to root store. It has to be install in CurrentUser's personal store. Which means the self signed certificate will not work, and you have to purchase a real certificate. :( I think this is a real thumb down to Microsoft. Why should I need to pay for real certificate for my dev/test environment? (Rant Over)

    For Service Fabric you will need to find out how to install certificate in Root Store as well as personal store (if thats possible at all). Here's Links that might be useful

    http://ronaldwildenberg.com/running-an-azure-service-fabric-cluster-locally-on-ssl/

    https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-cluster-security-update-certs-azure

    Hope this helps.