我有一个使用Azure WebJobs安排的控制台应用程序.尝试读取p12证书的私钥时,执行总是失败.有趣的是,我无法捕获异常,我不得不使用旧Console.WriteLine的调试.
这是我的代码片段:
var certificate = new X509Certificate2(data, "notasecret", X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { BigqueryService.Scope.Bigquery }
}.FromCertificate(certificate));
Run Code Online (Sandbox Code Playgroud)
其他帖子提到标志应该X509KeyStorageFlags.MachineKeySet但不幸的是,这会导致Google API出错.它需要设置X509KeyStorageFlags.Exportable标志.
任何人都可以确认X509KeyStorageFlags.Exportable在Azure网站和WebJobs上可用吗?