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
Copy file name to clipboardExpand all lines: articles/app-service/app-service-web-configure-tls-mutual-auth.md
+55-55Lines changed: 55 additions & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,34 +26,34 @@ You can restrict access to your Azure App Service app by enabling various types
26
26
27
27
## Enable client certificates
28
28
29
-
When you enable client certificates for your app, you should select your choice of client certificate mode. Each mode defines how your app handles incoming client certificates.
29
+
When you enable client certificates for your app, you should select your choice of client certificate mode. The mode defines how your app handles incoming client certificates. The modes are described in the following table:
30
30
31
31
|Client certificate mode|Description|
32
32
|-|-|
33
33
|Required|All requests require a client certificate.|
34
-
|Optional|Requests can use a client certificate and clients are prompted for a certificate by default. For example, browser clients show a prompt to select a certificate for authentication.|
35
-
|Optional Interactive User|Requests can use a client certificate and clients aren't prompted for a certificate by default. For example, browser clients don't show a prompt to select a certificate for authentication.|
34
+
|Optional|Requests can use a client certificate. Clients are prompted for a certificate by default. For example, browser clients show a prompt to select a certificate for authentication.|
35
+
|Optional Interactive User|Requests can use a client certificate. Clients aren't prompted for a certificate by default. For example, browser clients don't show a prompt to select a certificate for authentication.|
36
36
37
37
### [Azure portal](#tab/azureportal)
38
38
39
-
To use the Azure portal to set up your app to require client certificates:
39
+
To use the Azure portal to enable client certificates:
40
40
41
41
1. Go to your app management page.
42
-
1.On the left menu, select **Configuration** > **General Settings**.
42
+
1.In the left menu, select **Configuration** > **General Settings**.
43
43
1. For **Client certificate mode**, select your choice.
44
44
1. Select **Save**.
45
45
46
46
### [Azure CLI](#tab/azurecli)
47
47
48
-
To use the Azure CLI, run the following command in [Azure Cloud Shell](https://shell.azure.com):
48
+
To use the Azure CLI to enable client certificates, run the following command in [Azure Cloud Shell](https://shell.azure.com):
49
49
50
50
```azurecli-interactive
51
51
az webapp update --set clientCertEnabled=true --name <app-name> --resource-group <group-name>
52
52
```
53
53
54
54
### [Bicep](#tab/bicep)
55
55
56
-
For Bicep, modify the `clientCertEnabled`, `clientCertMode`, and `clientCertExclusionPaths` properties.
56
+
To enable client certificates in Bicep, modify the `clientCertEnabled`, `clientCertMode`, and `clientCertExclusionPaths` properties.
For Azure Resource Manager templates (ARM templates), modify the `clientCertEnabled`, `clientCertMode`, and `clientCertExclusionPaths` properties.
79
+
To enable client certificates in an Azure Resource Manager template (ARM template), modify the `clientCertEnabled`, `clientCertMode`, and `clientCertExclusionPaths` properties.
80
80
81
81
Here's a sample ARM template snippet:
82
82
@@ -110,56 +110,56 @@ When you enable mutual authentication for your application, all paths under the
110
110
> [!NOTE]
111
111
> Using any client certificate exclusion path triggers TLS renegotiation for incoming requests to the app.
112
112
113
-
1.On the left menu of your app management page, select **Configuration** > **General Settings**.
113
+
1.In the left menu of your app management page, select **Configuration** > **General Settings**.
114
114
115
115
1. Next to **Certificate exclusion paths**, select the edit icon.
116
116
117
117
1. Select **New path**, specify a path or a list of paths separated by `,` or `;`, and then select **OK**.
118
118
119
119
1. Select **Save**.
120
120
121
-
In the following screenshot, any pathfor your app that starts with `/public` doesn't request a client certificate. Path matching isn't case specific.
121
+
The following screenshot shows how to set a certificate exclusion path. Any path for the app that starts with `/public` doesn't request a client certificate. Path matching isn't case specific.
122
122
123
-
:::image type="content" source="media/app-service-web-configure-tls-mutual-auth/exclusion-paths.png" alt-text="Screenshot that shows setting a certificate exclusion path.":::
123
+
:::image type="content" source="media/app-service-web-configure-tls-mutual-auth/exclusion-paths.png" alt-text="Screenshot that shows how to set a certificate exclusion path." lightbox="media/app-service-web-configure-tls-mutual-auth/exclusion-paths.png":::
124
124
125
125
## Client certificate and TLS renegotiation
126
126
127
-
For some client certificate settings, 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:
127
+
For some client certificate settings, App Service requires TLS renegotiation to read a request before knowing whether to prompt for a client certificate. Both of the following settings trigger TLS renegotiation:
128
128
129
-
- Using the "Optional Interactive User" client certificate mode.
130
-
- Using the[client certificate exclusion path](#exclude-paths-from-requiring-authentication).
129
+
- Using the **Optional Interactive User** client certificate mode.
130
+
- Using a[client certificate exclusion path](#exclude-paths-from-requiring-authentication).
131
131
132
132
> [!NOTE]
133
133
> TLS 1.3 and HTTP 2.0 don't support TLS renegotiation. These protocols don't work if your app is configured with client certificate settings that use TLS renegotiation.
134
134
135
-
To disable TLS renegotiation and to have the app negotiate client certificates during TLS handshake, you must configure your app with *all* these settings:
135
+
To disable TLS renegotiation and have the app negotiate client certificates during TLS handshake, you must take the following actions in your app:
136
136
137
-
1. Set the client certificate mode to **Required** or **Optional**.
138
-
1. Remove all client certificate exclusion paths.
137
+
- Set the client certificate mode to **Required** or **Optional**.
138
+
- Remove all client certificate exclusion paths.
139
139
140
140
### Upload large files with TLS renegotiation
141
141
142
-
Client certificate configurations that use TLS renegotiation can't 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 fails with a 403 error. This limit isn't configurable and can't be increased.
142
+
Client certificate configurations that use TLS renegotiation can't support incoming requests with files that are larger than 100 KB. This limit is caused by buffer size limitations. In this scenario, any POST or PUT requests that are over 100 KB fail with a 403 error. This limit isn't configurable and can't be increased.
143
143
144
-
To address the 100-KB limit, consider these alternative solutions:
144
+
To address the 100-KB limit, consider these solutions:
145
145
146
-
1. Disable TLS renegotiation. Update your app's client certificate configurations with *all* these settings:
146
+
1. Disable TLS renegotiation. Take the following actions in your app's client certificate configurations:
147
147
- Set the client certificate mode to **Required** or **Optional**.
148
148
- Remove all client certificate exclusion paths.
149
149
1. Send a HEAD request before the PUT/POST request. The HEAD request handles the client certificate.
150
-
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.
150
+
1. Add the header `Expect: 100-Continue` to your request. This header causes the client to wait until the server responds with a `100 Continue` before sending the request body, and the buffers are bypassed.
151
151
152
152
## Access the client certificate
153
153
154
-
In App Service, TLS termination of the request happens at the front-end 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 forward it to your app. Your app code is responsible for validating the client certificate.
154
+
In App Service, TLS termination of the request happens at the front-end 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 forward it to your app. Your app code needs to validate the client certificate.
155
155
156
-
For ASP.NET, the client certificate is available through the `HttpRequest.ClientCertificate` property.
156
+
In ASP.NET, the client certificate is available through the `HttpRequest.ClientCertificate` property.
157
157
158
-
For other application stacks (Node.js, PHP), the client certificate is available in your app through a Base64-encoded value in the `X-ARR-ClientCert` request header.
158
+
In other application stacks (Node.js, PHP), the client certificate is available via a Base64-encoded value in the `X-ARR-ClientCert` request header.
159
159
160
160
## ASP.NET Core sample
161
161
162
-
For ASP.NET Core, middleware is provided to parse forwarded certificates. Separate middleware is provided to use the forwarded protocol headers. Both must be present for forwarded certificates to be accepted. You can place custom certificate validation logic in the [CertificateAuthentication options](/aspnet/core/security/authentication/certauth).
162
+
For ASP.NET Core, middleware is available to parse forwarded certificates. Separate middleware is available for using the forwarded protocol headers. Both must be present for forwarded certificates to be accepted. You can place custom certificate validation logic in the [CertificateAuthentication options](/aspnet/core/security/authentication/certauth):
@@ -490,7 +490,7 @@ public class ClientCertValidator {
490
490
491
491
## Python sample
492
492
493
-
The following Flask and Django Python code samples implement a decorator named `authorize_certificate` that can be used on a view function to permit access only to callers that present a valid client certificate. It expects a PEMformatted certificate in the `X-ARR-ClientCert` header and uses the Python [cryptography](https://pypi.org/project/cryptography/) package to validate the certificate based on its fingerprint (thumbprint), subject common name, issuer common name, and beginning and expiration dates. If validation fails, the decorator ensures that an HTTP response with status code 403 (Forbidden) is returned to the client.
493
+
The following Flask and Django Python code samples implement a decorator named `authorize_certificate` that can be used on a view function to permit access only to callers that present a valid client certificate. It expects a PEM-formatted certificate in the `X-ARR-ClientCert` header and uses the Python [cryptography](https://pypi.org/project/cryptography/) package to validate the certificate based on its fingerprint (thumbprint), subject common name, issuer common name, and beginning and expiration dates. If validation fails, the decorator ensures that an HTTP response with status code 403 (Forbidden) is returned to the client.
494
494
495
495
### [Flask](#tab/flask)
496
496
@@ -538,7 +538,7 @@ def validate_cert(request):
538
538
returnTrue
539
539
540
540
exceptExceptionas e:
541
-
# Handle any errors encountered during validation
541
+
# Handle any errors encountered during validation.
542
542
print(f"Encountered the following error during certificate validation: {e}")
543
543
returnFalse
544
544
@@ -607,7 +607,7 @@ def validate_cert(request):
607
607
returnTrue
608
608
609
609
exceptExceptionas e:
610
-
# Handle any errors encountered during validation
610
+
# Handle any errors encountered during validation.
611
611
print(f"Encountered the following error during certificate validation: {e}")
0 commit comments