我正在尝试使用Microsoft以编程方式创建Azure KeyVault密钥.Azure.KeyVault.KeyVaultClient.出于我的目的,我将使用证书作为Azure AD应用程序进行身份验证令牌身份验证.Azure AD应用程序已在其清单中包含证书信息.
我的代码创建Azure KeyVault,为Azure AD应用程序的对象ID提供密码和密钥的"所有"权限.我验证使用Powershell检索KeyVault并查看访问策略时发生了这种情况.
当我尝试使用KeyVaultClient.SetSecretAsync()在此KeyVault上创建一个秘密时,我得到一个异常,说"不允许操作'设置'." 状态代码为"Forbidden".
在KeyVault上设置的权限之外,我是否需要确保其他任何权限(如Azure AD应用程序)?
我有一个webjob从azure密钥保险库服务中获取证书,并且在本地我没有从kv访问/获取此证书的问题。但是,当部署此webjob时,出现此错误:
System.Security.Cryptography.CryptographicException: The system cannot find the file specified.
at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromBlob(Byte[] rawData, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx)
at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(Byte[] rawData, Object password, X509KeyStorageFlags keyStorageFlags)
at Microsoft.Ambassadors.Infrastructure.KeyVaultService.<GetCertificateAsync>d__7.MoveNext() in C:\Source\Repos\Xbox.Ambassadors\Microsoft.Ambassadors.Azure\Microsoft.Ambassadors.Infrastructure\KeyVaultService.cs:line 0
Run Code Online (Sandbox Code Playgroud)
我已经使用AAD注册了该应用程序(托管此Webjob的位置),并且该应用程序具有对kv空间的只读访问权限。我发现了一些与此相关的帖子(我认为..?):
“发生了内部错误。” 使用X509Certificate2加载pfx文件时
但是我不确定这是否可以解决我的问题...?如果有人可以提供帮助,那真是太好了!感谢:D