Search code examples
azure-web-app-serviceclient-certificates

How to implement TLS client certificate authentication for webistes deloyed on Azure?


I have a web app deployed on Azure. I want to restrict only devices with certificates to access the website. I know the certificate needs to be installed on the client device. But for the server side, I am not sure how to validate it. The website is developed using Java EE.


Solution

  • You could follow the steps below.

    1.Navigate to your web app in the portal -> Configuration -> General settings -> set Require incoming certificate to On. If you want to allow certain paths to remain open for anonymous access, you can define exclusion paths as part of your application configuration, see this link.

    enter image description here

    2.When forwarding the request to your app code with client certificates enabled, App Service injects an X-ARR-ClientCert request header with the client certificate.

    The client cert is available in your app through a base64 encoded value in the X-ARR-ClientCert request header, your app code is responsible for validating the client certificate.

    Reference - https://learn.microsoft.com/en-us/azure/app-service/app-service-web-configure-tls-mutual-auth#access-client-certificate

    There are just ASP.NET sample and Node.js sample in the officilal doc, you could take a look and implement it in java.