You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Configure TLS mutual authentication for Azure App Service
14
14
15
-
You can restrict access to your Azure App Service app by enabling different types of authentication for it. One way to do it is to request a client certificate when the client request is over TLS/SSL and validate the certificate. This mechanism is called TLS mutual authentication or client certificate authentication. This article shows how to set up your app to use client certificate authentication.
15
+
You can restrict access to your Azure App Service app by enabling different types of authentication for it. One way to do it is to request a client certificate when the client request is over TLS/SSL and validate the certificate. This mechanism is called Transport Layer Security (TLS) mutual authentication or client certificate authentication. This article shows how to set up your app to use client certificate authentication.
16
16
17
17
> [!NOTE]
18
18
> Your app code is responsible for validating the client certificate. App Service doesn't do anything with this client certificate other than forwarding it to your app.
@@ -22,27 +22,28 @@ You can restrict access to your Azure App Service app by enabling different type
22
22
[!INCLUDE [Prepare your web app](../../includes/app-service-ssl-prepare-app.md)]
23
23
24
24
## Enable client certificates
25
-
26
-
To set up your app to require client certificates:
27
-
28
-
1. From the left navigation of your app's management page, select **Configuration** > **General Settings**.
29
-
30
-
1. Select **Client certificate mode** of choice. Select **Save** at the top of the page.
25
+
When you enable client certificate for your app, you should select your choice of client certificate mode. Each mode defines how your app handles incoming client certificates:
31
26
32
27
|Client certificate modes|Description|
33
28
|-|-|
34
29
|Required|All requests require a client certificate.|
35
-
|Optional|Requests may or may not use a client certificate. Clients will be prompted for a certificate by default. For example, browser clients will show a prompt to select a certificate for authentication.|
36
-
|Optional Interactive User|Requests may or may not use a client certificate. Clients will not be prompted for a certificate by default. For example, browser clients will not show a prompt to select a certificate for authentication.|
30
+
|Optional|Requests may or may not use a client certificate and clients are prompted for a certificate by default. For example, browser clients will show a prompt to select a certificate for authentication.|
31
+
|Optional Interactive User|Requests may or may not use a client certificate and clients are not prompted for a certificate by default. For example, browser clients won't show a prompt to select a certificate for authentication.|
32
+
33
+
### [Azure portal](#tab/azureportal)
34
+
To set up your app to require client certificates in Azure portal:
35
+
1. Navigate to your app's management page.
36
+
1. From the left navigation of your app's management page, select **Configuration** > **General Settings**.
37
+
1. Select **Client certificate mode** of choice. Select **Save** at the top of the page.
37
38
38
39
### [Azure CLI](#tab/azurecli)
39
-
To do the same with Azure CLI, run the following command in the [Cloud Shell](https://shell.azure.com):
40
+
With Azure CLI, run the following command in the [Cloud Shell](https://shell.azure.com):
40
41
41
42
```azurecli-interactive
42
43
az webapp update --set clientCertEnabled=true --name <app-name> --resource-group <group-name>
43
44
```
44
-
### [Bicep](#tab/bicep)
45
45
46
+
### [Bicep](#tab/bicep)
46
47
For Bicep, modify the properties `clientCertEnabled`, `clientCertMode`, and `clientCertExclusionPaths`. A sample Bicep snippet is provided for you:
For ARM templates, modify the properties `clientCertEnabled`, `clientCertMode`, and `clientCertExclusionPaths`. A sample ARM template snippet is provided for you:
68
68
69
69
```ARM
@@ -93,6 +93,9 @@ For ARM templates, modify the properties `clientCertEnabled`, `clientCertMode`,
93
93
94
94
When you enable mutual auth for your application, all paths under the root of your app require a client certificate for access. To remove this requirement for certain paths, define exclusion paths as part of your application configuration.
95
95
96
+
> [!NOTE]
97
+
> Using any client certificate exclusion path triggers TLS renegotiation for incoming requests to the app.
98
+
96
99
1. From the left navigation of your app's management page, select **Configuration** > **General Settings**.
97
100
98
101
1. Next to **Certificate exclusion paths**, select the edit icon.
@@ -105,6 +108,29 @@ In the following screenshot, any path for your app that starts with `/public` do
105
108
106
109
![Certificate Exclusion Paths][exclusion-paths]
107
110
111
+
## Client certificate and TLS renegotiation
112
+
App Service requires TLS renegotiation to read a request before knowing whether to prompt for a client certificate. Any of the following settings triggers TLS renegotiation:
113
+
1. Using "Optional Interactive User" client certificate mode.
114
+
1. Using [client certificate exclusion path](#exclude-paths-from-requiring-authentication).
115
+
116
+
> [!NOTE]
117
+
> TLS 1.3 and HTTP 2.0 don't support TLS renegotiation. These protocols will not work if your app is configured with client certificate settings that use TLS renegotiation.
118
+
119
+
To disable TLS renegotiation and to have the app negotiate client certificates during TLS handshake, you must configure your app with *all* these settings:
120
+
1. Set client certificate mode to "Required" or "Optional"
121
+
2. Remove all client certificate exclusion paths
122
+
123
+
### Uploading large files with TLS renegotiation
124
+
Client certificate configurations that use TLS renegotiation cannot support incoming requests with large files greater than 100 kb due to buffer size limitations. In this scenario, any POST or PUT requests over 100 kb will fail with a 403 error. This limit isn't configurable and can't be increased.
125
+
126
+
To address the 100 kb limit, consider these alternative solutions:
127
+
128
+
1. Update your app's client certificate configurations with _all_ these settings:
129
+
- Set client certificate mode to either "Required" or "Optional"
130
+
- Remove all client certificate exclusion paths
131
+
1. Send a HEAD request before the PUT/POST request. The HEAD request handles the client certificate.
132
+
1. Add the header `Expect: 100-Continue` to your request. This causes the client to wait until the server responds with a `100 Continue` before sending the request body, which bypasses the buffers.
133
+
108
134
## Access client certificate
109
135
110
136
In App Service, TLS termination of the request happens at the frontend load balancer. When App Service forwards the request to your app code with [client certificates enabled](#enable-client-certificates), it injects an `X-ARR-ClientCert` request header with the client certificate. App Service doesn't do anything with this client certificate other than forwarding it to your app. Your app code is responsible for validating the client certificate.
0 commit comments