Azure Web AppsがAzure Key Vaultにアクセスできるように、私たちはサービス主体の証明書とアプリケーション登録を使用します。私のAzureアプリケーションの登録/サービスプリンシパルクレデンシャルはいつ期限切れになりますか?
証明書を生成した後、次のAzure PowerShellを使用してアプリケーション登録とサービスプリンシパルを作成し、サービスプリンシパルにAzure Key Vaultへのアクセス権を与えます。 Webアプリケーションはこの証明書をロードし、それを使ってAzure Key Vaultで認証します。それはすべて正常に動作します。
$subscriptionId = Read-Host -Prompt 'SubscriptionId'
Select-AzureRmSubscription -SubscriptionId $subscriptionId
$resourceGroupName = Read-Host -Prompt 'Resource group name'
$vaultName = Read-Host -Prompt 'Vault name'
$certificateName = Read-Host -Prompt 'Certificate name'
$applicationName = Read-Host -Prompt 'Application name'
$certificatePath = Join-Path (Get-Location) "$certificateName.cer"
$certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$certificate.Import($certificatePath)
$rawCertData = [System.Convert]::ToBase64String($certificate.GetRawCertData())
$now = [System.DateTime]::UtcNow
$application = New-AzureRmADApplication -DisplayName $applicationName -HomePage "https://$applicationName" -IdentifierUris "https://$applicationName" -CertValue $rawCertData -StartDate $now -EndDate $now.AddYears(1)
$servicePrincipal = New-AzureRmADServicePrincipal -ApplicationId $application.ApplicationId
Set-AzureRmKeyVaultAccessPolicy -ResourceGroupName $resourceGroupName -VaultName $vaultName -ServicePrincipalName "https://$applicationName" -PermissionsToSecrets get
問題は、この行です:
$application = New-AzureRmADApplication -DisplayName $applicationName -HomePage "https://$applicationName" -IdentifierUris "https://$applicationName" -CertValue $rawCertData -StartDate $now -EndDate $now.AddYears(1)
それは、現在の日付と現在の日付と1年にStartDate
とEndDate
を設定します。後知恵で私はそれが証明書の開始日と終了日となっているべきだと思う:
$application = New-AzureRmADApplication -DisplayName $applicationName -HomePage "https://$applicationName" -IdentifierUris "https://$applicationName" -CertValue $rawCertData -StartDate` $certificate.NotBefore -EndDate $certificate.NotAfter
私の質問がある - $now.AddYears(1)
後に何が起こりますか?証明書は3年間有効期限が切れて作成されましたが、アプリケーション登録/サービスプリンシパルは先にEndDate
で作成されましたが、それはどういう意味ですか?
私はこのシナリオをテストしていませんが、私は*推測*それはもう1年後にその証明書で署名要求を受け付けませんでしょう。 – juunas