|
1 | 1 | ---
|
2 |
| -title: Secure API Management backend using client certificate authentication |
| 2 | +title: Secure API Management Backend Using Client Certificate Authentication |
3 | 3 | titleSuffix: Azure API Management
|
4 |
| -description: Learn how to manage client certificates and secure backend services using client certificate authentication in Azure API Management. |
| 4 | +description: Learn how to manage client certificates and secure backend services by using client certificate authentication in Azure API Management. |
5 | 5 | services: api-management
|
6 | 6 | author: dlepow
|
7 | 7 |
|
8 | 8 | ms.service: azure-api-management
|
9 | 9 | ms.topic: how-to
|
10 |
| -ms.date: 01/12/2023 |
| 10 | +ms.date: 05/19/2025 |
11 | 11 | ms.author: danlep
|
12 | 12 | ms.custom: devx-track-azurepowershell, engagement-fy23
|
| 13 | + |
| 14 | +#customer intent: As an API developer, I want to secure backend services by using client certificate authentication. |
13 | 15 | ---
|
14 | 16 |
|
15 |
| -# Secure backend services using client certificate authentication in Azure API Management |
| 17 | +# Secure backend services by using client certificate authentication in Azure API Management |
16 | 18 |
|
17 | 19 | [!INCLUDE [api-management-availability-all-tiers](../../includes/api-management-availability-all-tiers.md)]
|
18 | 20 |
|
19 | 21 |
|
20 |
| -API Management allows you to secure access to the backend service of an API using client certificates and mutual TLS authentication. This guide shows how to manage certificates in an Azure API Management service instance using the Azure portal. It also explains how to configure an API to use a certificate to access a backend service. |
| 22 | +API Management allows you to secure access to the backend service of an API by using client certificates and mutual TLS authentication. This article shows how to manage certificates in API Management by using the Azure portal. It also explains how to configure an API to use a certificate to access a backend service. |
21 | 23 |
|
22 |
| -You can also manage API Management certificates using the [API Management REST API](/rest/api/apimanagement/current-ga/certificate). |
| 24 | +You can also manage API Management certificates by using the [API Management REST API](/rest/api/apimanagement/current-ga/certificate). |
23 | 25 |
|
24 | 26 | ## Certificate options
|
25 | 27 |
|
26 |
| -API Management provides two options to manage certificates used to secure access to backend services: |
| 28 | +API Management provides two options for managing certificates that are used to secure access to backend services: |
27 | 29 |
|
28 |
| -* Reference a certificate managed in [Azure Key Vault](/azure/key-vault/general/overview) |
29 |
| -* Add a certificate file directly in API Management |
| 30 | +* Reference a certificate that's managed in [Azure Key Vault](/azure/key-vault/general/overview). |
| 31 | +* Add a certificate file directly in API Management. |
30 | 32 |
|
31 |
| -Using key vault certificates is recommended because it helps improve API Management security: |
| 33 | +We recommend that you use key vault certificates because doing so improves API Management security: |
32 | 34 |
|
33 |
| -* Certificates stored in key vaults can be reused across services |
34 |
| -* Granular [access policies](/azure/key-vault/general/security-features#privileged-access) can be applied to certificates stored in key vaults |
35 |
| -* Certificates updated in the key vault are automatically rotated in API Management. After update in the key vault, a certificate in API Management is updated within 4 hours. You can also manually refresh the certificate using the Azure portal or via the management REST API. |
| 35 | +* Certificates stored in key vaults can be reused across services. |
| 36 | +* Granular [access policies](/azure/key-vault/general/security-features#privileged-access) can be applied to certificates stored in key vaults. |
| 37 | +* Certificates updated in the key vault are automatically rotated in API Management. After an update in the key vault, a certificate in API Management is updated within four hours. You can also manually refresh the certificate by using the Azure portal or via the management REST API. |
36 | 38 |
|
37 | 39 | ## Prerequisites
|
38 | 40 |
|
39 | 41 | [!INCLUDE [updated-for-az](~/reusable-content/ce-skilling/azure/includes/updated-for-az.md)]
|
40 | 42 |
|
41 |
| -* If you have not created an API Management service instance yet, see [Create an API Management service instance](get-started-create-service-instance.md). |
42 |
| -* You should have your backend service configured for client certificate authentication. To configure certificate authentication in the Azure App Service, refer to [this article][to configure certificate authentication in Azure WebSites refer to this article]. |
43 |
| -* You need access to the certificate and the password for management in an Azure key vault or upload to the API Management service. The certificate must be in **PFX** format. Self-signed certificates are allowed. |
| 43 | +* If you haven't created an API Management instance yet, see [Create an API Management service instance](get-started-create-service-instance.md). |
| 44 | +* Configure your backend service client certificate authentication. For information about configuring certificate authentication in Azure App Service, see [Configure TLS mutual authentication in App Service][to configure certificate authentication in Azure WebSites refer to this article]. |
| 45 | +* Ensure that you have access to the certificate and the password for management in an Azure key vault, or a certificate to upload to the API Management service. The certificate must be in PFX format. Self-signed certificates are allowed. |
44 | 46 |
|
45 | 47 | If you use a self-signed certificate:
|
46 | 48 | * Install trusted root and intermediate [CA certificates](api-management-howto-ca-certificates.md) in your API Management instance.
|
47 | 49 |
|
48 | 50 | > [!NOTE]
|
49 |
| - > CA certificates for certificate validation are not supported in the Consumption tier. |
50 |
| - * [Disable certificate chain validation](#disable-certificate-chain-validation-for-self-signed-certificates) |
| 51 | + > CA certificates for certificate validation aren't supported in the Consumption tier. |
| 52 | + * Disable certificate chain validation. See [Disable certificate chain validation for self-signed certificates](#disable-certificate-chain-validation-for-self-signed-certificates) later in this article. |
51 | 53 |
|
52 | 54 | [!INCLUDE [api-management-client-certificate-key-vault](../../includes/api-management-client-certificate-key-vault.md)]
|
53 | 55 |
|
54 |
| -After the certificate is uploaded, it shows in the **Certificates** window. If you have many certificates, make a note of the thumbprint of the desired certificate in order to configure an API to use a client certificate for [gateway authentication](#configure-an-api-to-use-client-certificate-for-gateway-authentication). |
| 56 | +After the certificate is uploaded, it shows in the **Certificates** window. If you have many certificates, note the thumbprint of the certificate that you just uploaded. You'll need it to configure an API to use the client certificate for [gateway authentication](#configure-an-api-to-use-client-certificate-for-gateway-authentication). |
55 | 57 |
|
56 | 58 |
|
57 | 59 | ## Configure an API to use client certificate for gateway authentication
|
58 | 60 |
|
59 |
| -1. In the [Azure portal](https://portal.azure.com), navigate to your API Management instance. |
| 61 | +1. In the [Azure portal](https://portal.azure.com), go to your API Management instance. |
60 | 62 | 1. Under **APIs**, select **APIs**.
|
61 | 63 | 1. Select an API from the list.
|
62 |
| -1. In the **Design** tab, select the editor icon in the **Backend** section. |
63 |
| -1. In **Gateway credentials**, select **Client cert** and select your certificate from the dropdown. |
| 64 | +1. On the **Design** tab, select the pencil icon in the **Backend** section. |
| 65 | +1. In **Gateway credentials**, select **Client cert** and then select your certificate in the **Client certificate** list. |
64 | 66 | 1. Select **Save**.
|
65 | 67 |
|
66 | 68 | :::image type="content" source="media/api-management-howto-mutual-certificates/apim-client-cert-enable-select.png" alt-text="Use client certificate for gateway authentication":::
|
67 | 69 |
|
68 | 70 | > [!CAUTION]
|
69 |
| -> This change is effective immediately, and calls to operations of that API will use the certificate to authenticate on the backend server. |
| 71 | +> This change is effective immediately. Calls to operations of the API will use the certificate to authenticate on the backend server. |
70 | 72 |
|
71 | 73 | > [!TIP]
|
72 | 74 | > When a certificate is specified for gateway authentication for the backend service of an API, it becomes part of the policy for that API and can be viewed in the policy editor.
|
73 | 75 |
|
74 | 76 | ## Disable certificate chain validation for self-signed certificates
|
75 | 77 |
|
76 |
| -If you are using self-signed certificates, you will need to disable certificate chain validation for API Management to communicate with the backend system. Otherwise it will return a 500 error code. To configure this, you can use the [`New-AzApiManagementBackend`](/powershell/module/az.apimanagement/new-azapimanagementbackend) (for new backend) or [`Set-AzApiManagementBackend`](/powershell/module/az.apimanagement/set-azapimanagementbackend) (for existing backend) PowerShell cmdlets and set the `-SkipCertificateChainValidation` parameter to `True`. |
| 78 | +If you're using self-signed certificates, you need to disable certificate chain validation to enable API Management to communicate with the backend system. Otherwise you'll get a 500 error code. To disable this validation, you can use the [`New-AzApiManagementBackend`](/powershell/module/az.apimanagement/new-azapimanagementbackend) (for a new backend) or [`Set-AzApiManagementBackend`](/powershell/module/az.apimanagement/set-azapimanagementbackend) (for an existing backend) PowerShell cmdlets and set the `-SkipCertificateChainValidation` parameter to `True`: |
77 | 79 |
|
78 | 80 | ```powershell
|
79 |
| -$context = New-AzApiManagementContext -resourcegroup 'ContosoResourceGroup' -servicename 'ContosoAPIMService' |
| 81 | +$context = New-AzApiManagementContext -ResourceGroupName 'ContosoResourceGroup' -ServiceName 'ContosoAPIMService' |
80 | 82 | New-AzApiManagementBackend -Context $context -Url 'https://contoso.com/myapi' -Protocol http -SkipCertificateChainValidation $true
|
81 | 83 | ```
|
82 | 84 |
|
83 | 85 | You can also disable certificate chain validation by using the [Backend](/rest/api/apimanagement/current-ga/backend) REST API.
|
84 | 86 |
|
85 | 87 | ## Delete a client certificate
|
86 | 88 |
|
87 |
| -To delete a certificate, select it and then select **Delete** from the context menu (**...**). |
| 89 | +To delete a certificate, select **Delete** on the ellipsis (**...**) menu: |
88 | 90 |
|
89 | 91 | :::image type="content" source="media/api-management-howto-mutual-certificates/apim-client-cert-delete-new.png" alt-text="Delete a certificate":::
|
90 | 92 |
|
91 | 93 | > [!IMPORTANT]
|
92 |
| -> If the certificate is referenced by any policies, then a warning screen is displayed. To delete the certificate, you must first remove the certificate from any policies that are configured to use it. |
| 94 | +> If the certificate is referenced by any policies, a warning screen appears. To delete the certificate, you must first remove it from any policies that are configured to use it. |
93 | 95 |
|
94 | 96 | ## Related content
|
95 | 97 |
|
96 | 98 | * [How to secure APIs using client certificate authentication in API Management](api-management-howto-mutual-certificates-for-clients.md)
|
97 | 99 | * [How to add a custom CA certificate in Azure API Management](./api-management-howto-ca-certificates.md)
|
98 |
| -* Learn about [policies in API Management](api-management-howto-policies.md) |
| 100 | +* [Policies in API Management](api-management-howto-policies.md) |
99 | 101 |
|
100 | 102 |
|
101 | 103 | [How to add operations to an API]: ./mock-api-responses.md
|
|
0 commit comments