Bereitstellen eines Azure-Anwendungsgateways mit mTLS-Passthrough-Listener

In dieser Schnellstartanleitung erfahren Sie, wie Sie eine Azure Application Gateway mit mutual TLS (mTLS)-Passthrough mithilfe einer Azure Resource Manager Vorlage (ARM-Vorlage) und einer API-Version 2025-03-01 bereitstellen. Im Passthrough-Modus fordert das Gateway ein Clientzertifikat an, überprüft es jedoch nicht. Zertifikatüberprüfung und Richtlinienerzwingung erfolgen im Back-End.

Wichtigste Funktionen

  • Ordnen Sie dem Listener für mTLS-Passthrough ein SSL-Profil zu.
  • Am Gateway wird kein Zertifikat einer Client-CA benötigt.
  • Die verifyClientAuthMode Eigenschaft unterstützt Strict und Passthrough Werte.
  • Portal-Unterstützung: Sie können mTLS-Passthrough direkt im Azure-Portal konfigurieren.

Hinweis

PowerShell- und CLI-Unterstützung für die Passthroughkonfiguration sind derzeit nicht verfügbar. Sie können die mTLS-Passthrough mithilfe der Azure Portal- oder ARM-Vorlagen konfigurieren.

Konfigurieren der mTLS-Passthrough mithilfe des Azure-Portals

Sie können mTLS-Passthrough direkt im Azure Portal konfigurieren, indem Sie ein SSL-Profil mit der Passthrough Clientauthentifizierungsmethode erstellen:

  1. Navigieren Sie im Azure-Portal zu Ihrer Application Gateway-Ressource.

  2. Wählen Sie unter "Einstellungen"SSL-Profile aus.

  3. Wählen Sie +Hinzufügen aus, um ein neues SSL-Profil zu erstellen.

  4. Geben Sie einen Namen für Ihr SSL-Profil ein.

  5. Wählen Sie auf der Registerkarte "Clientauthentifizierung " die Option "Passthrough" aus.

    Im Passthrough-Modus ist das Clientzertifikat optional, und der Back-End-Server ist für die Clientauthentifizierung verantwortlich.

Screenshot mit dem Dialogfeld

  1. Konfigurieren Sie die SSL-Richtlinieneinstellungen nach Bedarf.
  2. Wählen Sie "Hinzufügen" aus, um das SSL-Profil zu erstellen.
  3. Ordnen Sie das SSL-Profil Ihrem HTTPS-Listener zu.

Voraussetzungen

  • Ein Azure-Abonnement und eine Ressourcengruppe.
  • Azure CLI lokal installiert.
  • Ein SSL-Zertifikat (Base64-codierte PFX) und ein Kennwort.
  • Ein SSH-Schlüssel für linux-VM-Administrator (falls zutreffend).
  • API-Version 2025-03-01 oder höher für die Passthrough-Eigenschaft.

Bereitstellen des Anwendungsgateways mit mTLS-Passthrough-Listener

Diese Vorlage erstellt die folgenden Ressourcen:

  • Ein virtuelles Netzwerk mit zwei Subnetzen (eines, das an das Anwendungsgateway delegiert wird).
  • Eine öffentliche IP-Adresse für das Gateway-Frontend.
  • Ein Anwendungsgateway (Standard_v2) mit:
    • SSL-Zertifikat und SSL-Profil für Passthrough von Clientzertifikaten.
    • HTTPS-Listener und Routingregel.
    • Backend-Pool, der auf einen App-Service zeigt.

Aktualisieren Sie die Vorlage mit Ihren Konfigurationsdetails, und fügen Sie ein gültiges SSL-Zertifikat ein.

Parameterdatei: deploymentParameters.json

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "addressPrefix": {
            "value": "10.0.0.0/16"
        },
        "subnetPrefix": {
            "value": "10.0.0.0/24"
        },
        "skuName": {
            "value": "Standard_v2"
        },
        "capacity": {
            "value": 2
        },
        "adminUsername": {
            "value": "ubuntu"
        },
        "adminSSHKey": {
            "value": "<your-ssh-public-key>"
        },
        "certData": {
            "value": "<Base64-encoded-PFX-data>"
        },
        "certPassword": {
            "value": "<certificate-password>"
        }
    }
}

Vorlagendatei: deploymentTemplate.json

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "addressPrefix": {
            "defaultValue": "10.0.0.0/16",
            "type": "String",
            "metadata": {
                "description": "Address prefix for the Virtual Network"
            }
        },
        "subnetPrefix": {
            "defaultValue": "10.0.0.0/24",
            "type": "String",
            "metadata": {
                "description": "Subnet prefix"
            }
        },
        "skuName": {
            "defaultValue": "Standard_Medium",
            "type": "String",
            "metadata": {
                "description": "Sku Name"
            }
        },
        "capacity": {
            "defaultValue": 2,
            "type": "Int",
            "metadata": {
                "description": "Number of instances"
            }
        },
        "adminUsername": {
            "type": "String"
        },
		"adminSSHKey": {
            "type": "securestring"
        },
        "certData": {
            "type": "String",
            "metadata": {
                "description": "ssl cert data"
            }
        },
        "certPassword": {
            "type": "SecureString",
            "metadata": {
                "description": "ssl cert password"
            }
        }
    },
    "variables": {
        "applicationGatewayName": "mtlsAppGw",
        "idName": "identity",
        "publicIPAddressName": "mtlsPip",
        "virtualNetworkName": "mtlsVnet",
        "subnetName": "appgwsubnet",
        "vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
        "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]",
        "publicIPRef": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]",
        "applicationGatewayID": "[resourceId('Microsoft.Network/applicationGateways',variables('applicationGatewayName'))]",
        "apiVersion": "2025-03-01",
        "identityID": "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities',variables('idName'))]",
        "backendSubnetId": "[concat(variables('vnetID'),'/subnets/backendsubnet')]"
    },
    "resources": [
        {
            "type": "Microsoft.Network/virtualNetworks",
            "name": "[variables('virtualNetworkName')]",
            "apiVersion": "2024-07-01",
            "location": "[resourceGroup().location]",
            "properties": {
                "addressSpace": {
                    "addressPrefixes": [
                        "[parameters('addressPrefix')]"
                    ]
                },
                "subnets": [
                    {
                        "name": "[variables('subnetName')]",
                        "properties": {
                            "addressPrefix": "[parameters('subnetPrefix')]",
                             "delegations": [
                                {
                                    "name": "Microsoft.Network/applicationGateways",
                                    "properties": {
                                        "serviceName": "Microsoft.Network/applicationGateways"
                                    }
                                }
                            ]
                        }
                    },
                    {
                        "name": "backendSubnet",
                        "properties": {
                            "addressPrefix": "10.0.2.0/24"
                        }
                    }
                ]
            }
        },
        {
            "type": "Microsoft.Network/publicIPAddresses",
            "sku": {
                "name": "Standard"
            },
            "name": "[variables('publicIPAddressName')]",
            "apiVersion": "2024-07-01",
            "location": "[resourceGroup().location]",
            "properties": {
                "publicIPAllocationMethod": "Static"
            }
        },
        {
            "type": "Microsoft.Network/applicationGateways",
            "name": "[variables('applicationGatewayName')]",
            "apiVersion": "[variables('apiVersion')]",
            "location": "[resourceGroup().location]",
            "properties": {
                "sku": {
                    "name": "Standard_v2",
                    "tier": "Standard_v2",
                    "capacity": 3
                },
                "sslCertificates": [
                    {
                        "name": "sslCert",
                        "properties": {
                            "data": "[parameters('certData')]",
                            "password": "[parameters('certPassword')]"
                        }
                    }
                ],
                "sslPolicy": {
                    "policyType": "Predefined",
                    "policyName": "AppGwSslPolicy20220101"
                },
                "sslProfiles": [
                    {
                        "name": "sslnotrustedcert",
                        "id": "[concat(resourceId('Microsoft.Network/applicationGateways',  variables('applicationGatewayName')), '/sslProfiles/sslnotrustedcert')]",
                        "properties": {
                            "clientAuthConfiguration": {
                                "VerifyClientCertIssuerDN": false,
                                "VerifyClientRevocation": "None",
                                "VerifyClientAuthMode": "Passthrough"
                            }
                        }
                    }                   
                ],
                "gatewayIPConfigurations": [
                    {
                        "name": "appGatewayIpConfig",
                        "properties": {
                            "subnet": {
                                "id": "[variables('subnetRef')]"
                            }
                        }
                    }
                ],
                "frontendIPConfigurations": [
                    {
                        "name": "appGatewayFrontendIP",
                        "properties": {
                            "PublicIPAddress": {
                                "id": "[variables('publicIPRef')]"
                            }
                        }
                    }
                ],
                "frontendPorts": [
                    {
                        "name": "port2",
                        "properties": {
                            "Port": 444
                        }
                    }
                ],
                "backendAddressPools": [
                    {
                        "name": "pool2",
                        "properties": {
                            "BackendAddresses": [
							  {
                                "fqdn": "headerappgw-hsa5gjh8fpfebcfd.westus-01.azurewebsites.net"
                              }
							]
                        }
                    }
                ],
                "backendHttpSettingsCollection": [
                    {
                        "name": "settings2",
                        "properties": {
                            "Port": 80,
                            "Protocol": "Http"
                        }
                    }
                ],
                "httpListeners": [
                    {
                        "name": "listener2",
                        "properties": {
                            "FrontendIPConfiguration": {
                                "Id": "[concat(variables('applicationGatewayID'), '/frontendIPConfigurations/appGatewayFrontendIP')]"
                            },
                            "FrontendPort": {
                                "Id": "[concat(variables('applicationGatewayID'), '/frontendPorts/port2')]"
                            },
                            "Protocol": "Https",
                            "SslCertificate": {
                                "Id": "[concat(variables('applicationGatewayID'), '/sslCertificates/sslCert')]"
                            },
                            "sslProfile": {
                                "id": "[concat(variables('applicationGatewayID'), '/sslProfiles/sslnotrustedcert')]"
                            }
                        }
                    }
                ],
                "requestRoutingRules": [
                    {
                        "Name": "rule2",
                        "properties": {
                            "RuleType": "Basic",
                            "priority": 2000,
                            "httpListener": {
                                "id": "[concat(variables('applicationGatewayID'), '/httpListeners/listener2')]"
                            },
                            "backendAddressPool": {
                                "id": "[concat(variables('applicationGatewayID'), '/backendAddressPools/pool2')]"
                            },
                            "backendHttpSettings": {
                                "id": "[concat(variables('applicationGatewayID'), '/backendHttpSettingsCollection/settings2')]"
                            }
                        }
                    }
                ]
            },
            "dependsOn": [
                "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]",
                "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]"
            ]
        }
    ]
}

Implementieren der Vorlage

Führen Sie den folgenden Azure CLI Befehl aus, um die Vorlage bereitzustellen:

az deployment group create \
  --resource-group <your-resource-group> \
  --template-file deploymentTemplate.json \
  --parameters @deploymentParameters.json

Überprüfen und Testen

Validierung der Bereitstellung

  1. Navigieren Sie im Azure-Portal zu Ihrer Application Gateway-Ressource.

  2. Wählen Sie JSON-Ansicht und api-Version 2025-03-01aus.

  3. Überprüfen Sie, ob verifyClientAuthMode im SSL-Profil auf Passthrough festgelegt ist.

    "sslProfiles": [
        {
            "name": "sslnotrustedcert",
            "id": "<sample-subscription-id>",
            "etag": "W/\"851e4e20-d2b1-4338-9135-e0beac11aa0e\"",
            "properties": {
                "provisioningState": "Succeeded",
                "clientAuthConfiguration": {
                    "verifyClientCertIssuerDN": false,
                    "verifyClientRevocation": "None",
                    "verifyClientAuthMode": "Passthrough"
                },
                "httpListeners": [
                    {
                        "id": "<sample-subscription-id>"
                    }
                ]
            }
        }
    ]
    

Senden eines Clientzertifikats an das Back-End

Wenn Sie das Clientzertifikat an das Back-End weiterleiten müssen, konfigurieren Sie eine Neuschreibregel. Weitere Informationen finden Sie unter "Rewrite HTTP headers and URL with Application Gateway".

Wenn der Client ein Zertifikat sendet, stellt diese Neuschreibung sicher, dass das Clientzertifikat in den Anforderungsheadern für die Back-End-Verarbeitung enthalten ist.

Testen der Konnektivität

Stellen Sie sicher, dass Verbindungen auch dann hergestellt werden, wenn kein Clientzertifikat bereitgestellt wird.

mTLS-Passthrough-Parameter

In der folgenden Tabelle werden die Parameter für die mTLS-Passthroughkonfiguration beschrieben:

Name Typ Description
verifyClientCertIssuerDN Boolean Gibt an, ob der Name des Clientzertifikatherausgebers auf dem Gateway überprüft werden soll.
verifyClientRevocation String Gibt den Verifikationsmodus für die Sperrung von Clientzertifikaten an.
verifyClientAuthMode String Gibt den Clientzertifikatmodus an. Gültige Werte sind Strict und Passthrough.

Passthrough-Modus: Das Gateway fordert ein Clientzertifikat an, erzwingt es jedoch nicht. Das Back-End überprüft das Zertifikat und erzwingt die Richtlinie.

Sicherheitsaspekte

Befolgen Sie die bewährten Methoden zur Sicherheit und Datenverarbeitung Ihrer Organisation, wenn Sie diese Lösung bereitstellen und verwalten.