Konfigurasikan versi kebijakan TLS dan cipher suite di Application Gateway

Belajar mengonfigurasi versi kebijakan TLS/SSL dan cipher suite di Application Gateway. Anda dapat memilih dari daftar kebijakan yang telah dibuat sebelumnya yang berisi berbagai versi kebijakan TLS dan aktivasi cipher suite. Anda juga dapat menentukan kebijakan TLS kustom sesuai kebutuhan Anda.

Catatan

Sebaiknya Anda menggunakan modul Azure Az PowerShell untuk berinteraksi dengan Azure. Lihat Menginstal Azure PowerShell untuk memulai. Untuk mempelajari cara bermigrasi ke modul Az PowerShell, lihat Memigrasikan Azure PowerShell dari AzureRM ke Az.

Catatan

Sebaiknya gunakan TLS 1.2 sebagai versi protokol TLS minimum untuk keamanan yang lebih baik di Application Gateway Anda.

Dapatkan opsi TLS yang tersedia

Cmdlet Get-AzApplicationGatewayAvailableSslOptions menyediakan daftar kebijakan yang dibuat sebelumnya, cipher suite yang tersedia, dan versi protokol yang dapat dikonfigurasi. Contoh berikut menunjukkan contoh output dari menjalankan cmdlet.

Penting

Kebijakan TLS default diatur ke AppGwSslPolicy20220101 untuk API versi 2023-02-01 atau yang lebih tinggi. Kunjungi gambaran umum kebijakan TLS untuk mengetahui lebih lanjut.

DefaultPolicy: AppGwSslPolicy20150501
PredefinedPolicies:
    /subscriptions/xxx-xxx/resourceGroups//providers/Microsoft.Network/ApplicationGatewayAvailableSslOptions/default/Applic
ationGatewaySslPredefinedPolicy/AppGwSslPolicy20150501
    /subscriptions/xxx-xxx/resourceGroups//providers/Microsoft.Network/ApplicationGatewayAvailableSslOptions/default/Applic
ationGatewaySslPredefinedPolicy/AppGwSslPolicy20170401
    /subscriptions/xxx-xxx/resourceGroups//providers/Microsoft.Network/ApplicationGatewayAvailableSslOptions/default/Applic
ationGatewaySslPredefinedPolicy/AppGwSslPolicy20170401S
    /subscriptions/xxx-xxx/resourceGroups//providers/Microsoft.Network/ApplicationGatewayAvailableSslOptions/default/Applic
ationGatewaySslPredefinedPolicy/AppGwSslPolicy20220101
    /subscriptions/xxx-xxx/resourceGroups//providers/Microsoft.Network/ApplicationGatewayAvailableSslOptions/default/Applic
ationGatewaySslPredefinedPolicy/AppGwSslPolicy20220101S

AvailableCipherSuites:
    TLS_AES_128_GCM_SHA256
    TLS_AES_256_GCM_SHA384
    TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
    TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
    TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
    TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
    TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
    TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
    TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
    TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
    TLS_DHE_RSA_WITH_AES_256_CBC_SHA
    TLS_DHE_RSA_WITH_AES_128_CBC_SHA
    TLS_RSA_WITH_AES_256_GCM_SHA384
    TLS_RSA_WITH_AES_128_GCM_SHA256
    TLS_RSA_WITH_AES_256_CBC_SHA256
    TLS_RSA_WITH_AES_128_CBC_SHA256
    TLS_RSA_WITH_AES_256_CBC_SHA
    TLS_RSA_WITH_AES_128_CBC_SHA
    TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
    TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
    TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
    TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
    TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
    TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
    TLS_DHE_DSS_WITH_AES_256_CBC_SHA256
    TLS_DHE_DSS_WITH_AES_128_CBC_SHA256
    TLS_DHE_DSS_WITH_AES_256_CBC_SHA
    TLS_DHE_DSS_WITH_AES_128_CBC_SHA
    TLS_RSA_WITH_3DES_EDE_CBC_SHA
    TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA

AvailableProtocols:
    TLSv1_0
    TLSv1_1
    TLSv1_2
    TLSv1_3

Daftar Kebijakan TLS yang telah dibuat sebelumnya

Gateway aplikasi dilengkapi dengan beberapa kebijakan yang telah ditentukan sebelumnya yang dapat digunakan. Cmdlet Get-AzApplicationGatewaySslPredefinedPolicy mengambil kebijakan ini. Setiap kebijakan memiliki aktivasi versi protokol dan cipher suite yang berbeda. Kebijakan yang dibuat sebelumnya ini dapat digunakan untuk mengonfigurasi kebijakan TLS dengan cepat di application gateway Anda. AppGwSslPolicy20150501 secara default dipilih jika tidak ada kebijakan TLS spesifik ditentukan.

Output berikut adalah contoh menjalankan Get-AzApplicationGatewaySslPredefinedPolicy.

Name: AppGwSslPolicy20150501
MinProtocolVersion: TLSv1_0
CipherSuites:
    TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
    TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
    TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
    TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
    TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
    TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
    TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
    TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
    TLS_DHE_RSA_WITH_AES_256_CBC_SHA
    TLS_DHE_RSA_WITH_AES_128_CBC_SHA
    TLS_RSA_WITH_AES_256_GCM_SHA384
 ...
Name: AppGwSslPolicy20170401
MinProtocolVersion: TLSv1_1
CipherSuites:
    TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
    TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
    TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
    TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
    TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
    TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
    TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
...

Mengonfigurasi kebijakan TLS kustom

Saat mengonfigurasi kebijakan TLS kustom, Anda melewati parameter berikut: PolicyType, MinProtocolVersion, CipherSuite, dan ApplicationGateway. Jika Anda mencoba untuk melewati parameter lain, kesalahan akan muncul saat membuat atau memperbarui Application Gateway. Contoh berikut menetapkan kebijakan TLS kustom pada application gateway. Ini mengatur versi protokol minimum ke TLSv1_1 dan mengaktifkan cipher suite berikut:

  • TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
  • TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
# get an application gateway resource
$gw = Get-AzApplicationGateway -Name AdatumAppGateway -ResourceGroup AdatumAppGatewayRG

# set the TLS policy on the application gateway
Set-AzApplicationGatewaySslPolicy -ApplicationGateway $gw -PolicyType Custom -MinProtocolVersion TLSv1_1 -CipherSuite "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"

# validate the TLS policy locally
Get-AzApplicationGatewaySslPolicy -ApplicationGateway $gw

# update the gateway with validated TLS policy
Set-AzApplicationGateway -ApplicationGateway $gw

Penting

  • Jika Anda menggunakan kebijakan SSL kustom di Application Gateway v1 SKU (Standar atau WAF), pastikan Anda menambahkan sandi wajib "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" ke daftar. Cipher ini diperlukan untuk mengaktifkan metrik dan pengelogan di Application Gateway v1 SKU. Tidak wajib untuk Application Gateway v2 SKU (Standard_v2 atau WAF_v2).
  • Cipher suite "TLS_AES_128_GCM_SHA256" dan "TLS_AES_256_GCM_SHA384" dengan TLSv1.3 tidak dapat disesuaikan dan disertakan secara default saat mengatur kebijakan CustomV2 dengan versi TLS minimum 1.2 atau 1.3. Kedua suite sandi ini tidak akan muncul di output Dapatkan Detail, dengan pengecualian Portal.

Untuk mengatur versi protokol minimum ke 1.3, Anda harus menggunakan perintah berikut:

Set-AzApplicationGatewaySslPolicy -ApplicationGateway $AppGW -MinProtocolVersion TLSv1_3 -PolicyType CustomV2 -CipherSuite @()

Ilustrasi ini lebih lanjut menjelaskan penggunaan kebijakan CustomV2 dengan protokol minimum versi 1.2 dan 1.3.

Diagram that shows use of ciphersuite parameter for the CustomV2 policy.

Membuat application gateway dengan kebijakan TLS yang dibuat sebelumnya

Saat mengonfigurasi Kebijakan TLS yang dibuat sebelumnya, Anda melewati parameter berikut: PolicyType, PolicyName, dan ApplicationGateway. Jika Anda mencoba untuk melewati parameter lain, kesalahan akan muncul saat membuat atau memperbarui Application Gateway.

Berikut ini contoh untuk membuat application gateway baru dengan kebijakan TLS yang dibuat sebelumnya.

# Create a resource group
$rg = New-AzResourceGroup -Name ContosoRG -Location "East US"

# Create a subnet for the application gateway
$subnet = New-AzVirtualNetworkSubnetConfig -Name subnet01 -AddressPrefix 10.0.0.0/24

# Create a virtual network with a 10.0.0.0/16 address space
$vnet = New-AzVirtualNetwork -Name appgwvnet -ResourceGroupName $rg.ResourceGroupName -Location "East US" -AddressPrefix 10.0.0.0/16 -Subnet $subnet

# Retrieve the subnet object for later use
$subnet = $vnet.Subnets[0]

# Create a public IP address
$publicip = New-AzPublicIpAddress -ResourceGroupName $rg.ResourceGroupName -name publicIP01 -location "East US" -AllocationMethod Dynamic

# Create an ip configuration object
$gipconfig = New-AzApplicationGatewayIPConfiguration -Name gatewayIP01 -Subnet $subnet

# Create a backend pool for backend web servers
$pool = New-AzApplicationGatewayBackendAddressPool -Name pool01 -BackendIPAddresses 134.170.185.46, 134.170.188.221,134.170.185.50

# Define the backend http settings to be used.
$poolSetting = New-AzApplicationGatewayBackendHttpSettings -Name poolsetting01 -Port 80 -Protocol Http -CookieBasedAffinity Enabled

# Create a new port for TLS
$fp = New-AzApplicationGatewayFrontendPort -Name frontendport01  -Port 443

# Upload an existing pfx certificate for TLS offload
$password = ConvertTo-SecureString -String "P@ssw0rd" -AsPlainText -Force
$cert = New-AzApplicationGatewaySslCertificate -Name cert01 -CertificateFile C:\folder\contoso.pfx -Password $password

# Create a frontend IP configuration for the public IP address
$fipconfig = New-AzApplicationGatewayFrontendIPConfig -Name fipconfig01 -PublicIPAddress $publicip

# Create a new listener with the certificate, port, and frontend ip.
$listener = New-AzApplicationGatewayHttpListener -Name listener01  -Protocol Https -FrontendIPConfiguration $fipconfig -FrontendPort $fp -SslCertificate $cert

# Create a new rule for backend traffic routing
$rule = New-AzApplicationGatewayRequestRoutingRule -Name rule01 -RuleType Basic -BackendHttpSettings $poolSetting -HttpListener $listener -BackendAddressPool $pool

# Define the size of the application gateway
$sku = New-AzApplicationGatewaySku -Name Standard_Small -Tier Standard -Capacity 2

# Configure the TLS policy to use a different pre-defined policy
$policy = New-AzApplicationGatewaySslPolicy -PolicyType Predefined -PolicyName AppGwSslPolicy20170401S

# Create the application gateway.
$appgw = New-AzApplicationGateway -Name appgwtest -ResourceGroupName $rg.ResourceGroupName -Location "East US" -BackendAddressPools $pool -BackendHttpSettingsCollection $poolSetting -FrontendIpConfigurations $fipconfig  -GatewayIpConfigurations $gipconfig -FrontendPorts $fp -HttpListeners $listener -RequestRoutingRules $rule -Sku $sku -SslCertificates $cert -SslPolicy $policy

Memperbarui application gateway yang sudah ada dengan kebijakan TLS yang dibuat sebelumnya

Untuk mengatur kebijakan TLS kustom, Anda melewati parameter berikut: PolicyType, MinProtocolVersion, CipherSuite, dan ApplicationGateway. Untuk mengatur Kebijakan TLS yang dibuat sebelumnya, Anda melewati parameter berikut: PolicyType, PolicyName, dan ApplicationGateway. Jika Anda mencoba untuk melewati parameter lain, kesalahan akan muncul saat membuat atau memperbarui Application Gateway.

Catatan

Menggunakan kebijakan Predefined atau Customv2 baru meningkatkan postur keamanan dan performa SSL dari seluruh gateway (Kebijakan SSL dan Profil SSL). Oleh karena itu, kebijakan lama dan baru tidak dapat ada bersamaan. Anda diharuskan untuk menggunakan salah satu kebijakan lama yang telah ditentukan atau kustom di seluruh gateway, jika ada klien yang memerlukan versi atau sandi TLS yang lebih lama (misalnya, TLS v1.0).

Dalam contoh berikut, ada sampel kode untuk Kebijakan Kustom dan Kebijakan yang Dibuat Sebelumnya. Urungkan kebijakan yang ingin Anda gunakan.

# You have to change these parameters to match your environment.
$AppGWname = "YourAppGwName"
$RG = "YourResourceGroupName"

$AppGw = get-Azapplicationgateway -Name $AppGWname -ResourceGroupName $RG

# Choose either custom policy or predefined policy and uncomment the one you want to use.

# TLS Custom Policy
# Set-AzApplicationGatewaySslPolicy -PolicyType Custom -MinProtocolVersion TLSv1_2 -CipherSuite "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_RSA_WITH_AES_128_CBC_SHA256" -ApplicationGateway $AppGw

# TLS Predefined Policy
# Set-AzApplicationGatewaySslPolicy -PolicyType Predefined -PolicyName "AppGwSslPolicy20170401S" -ApplicationGateway $AppGW

# Update AppGW
# The TLS policy options are not validated or updated on the Application Gateway until this cmdlet is executed.
$SetGW = Set-AzApplicationGateway -ApplicationGateway $AppGW

Langkah berikutnya

Kunjungi Gambaran umum pengalihan Application Gateway untuk mempelajari cara mengalihkan lalu lintas HTTP ke titik akhir HTTPS.

Lihat di setting up SSL listener specific policy through Portal untuk menyiapkan kebijakan SSL spesifik listener