【发布时间】:2016-06-08 23:33:36
【问题描述】:
我尝试使用 Azure PowerShell 证书身份验证在 Azure AD 中创建应用程序,下面是 Powershell sn-p:
Login-AzureRmAccount
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate("PATH_TO_CER_FILE")
$key = [System.Convert]::ToBase64String($cert.GetRawCertData())
$app = New-AzureRmADApplication -DisplayName "SetupTet4" -HomePage "http://localhost" -IdentifierUris "http://localhost" -KeyValue $key -KeyType AsymmetricX509Cert
New-AzureRmADServicePrincipal -ApplicationId $app.ApplicationId
New-AzureRmRoleAssignment -RoleDefinitionName "Owner" -ServicePrincipalName $app.ApplicationId
Azure AD 应用程序已成功创建,但是对于具有证书身份验证的 Azure AD 应用程序,customKeyIdentifier 和 keyCredentials 中的值在创建后为 null,这是我从 Azure 下载的应用程序清单的一部分传送门:
"keyCredentials": [{
"customKeyIdentifier": null,
"endDate": "2017-02-25T20:48:35.5174541Z",
"keyId": "575580cc-ce4e-4862-ad3e-1ba5833fe7f6",
"startDate": "2016-02-25T20:48:35.5174541Z",
"type": "AsymmetricX509Cert",
"usage": "Verify",
"value": null
}],
仅供参考,证书是我使用本地生成的 makecert 命令的自签名证书。
任何建议,非常感谢。
詹姆斯
【问题讨论】:
-
有什么问题?您发布的步骤是在 Azure AD 中创建应用程序的步骤。您对 customKeyIdentifier 和 value 为 null 有什么顾虑?
-
Rick,谢谢你的提问,这就是问题所在,如果 customKeyIdentifier 和 value 为 null,App Authentication 将失败。
-
我也尝试了 Graph API,请遵循以下代码:[link] (github.com/Azure-Samples/…) 但结果相同,customKeyIdentifier 和 value 为 null,这是 MS API 中的错误还是我错过了什么?
-
我刚刚注意到您缺少什么 - “Set-AzureRmKeyVaultAccessPolicy”。我部署了相同的环境。我刚刚检查了我的脚本,发现你的脚本中没有这个。我会在几分钟后将其作为解决方案发布,以便您查看全部内容。
标签: azure certificate azure-active-directory azure-powershell azure-keyvault