Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将证书作为嵌入资源加载到程序集中_C#_Azure_Certificate_Embedded Resource_X509certificate2 - Fatal编程技术网

C# 将证书作为嵌入资源加载到程序集中

C# 将证书作为嵌入资源加载到程序集中,c#,azure,certificate,embedded-resource,x509certificate2,C#,Azure,Certificate,Embedded Resource,X509certificate2,我在程序集中添加了一个PFX文件作为嵌入式资源,以使用证书对JWT令牌进行签名。我将pfx作为流加载,读取所有字节,并使用X509Certificate2加载私钥 公共X509Certificate2(字节[]原始数据,字符串密码) 在Debug/Release中都可以在dev机器上正常工作,但是当部署到azure apps服务或构建机器时,我看到了“坏数据”错误 非常感谢您的帮助。 谢谢您似乎想访问Azure app Service web app上应用程序的证书,您可以将证书上载到Azure

我在程序集中添加了一个PFX文件作为嵌入式资源,以使用证书对JWT令牌进行签名。我将pfx作为流加载,读取所有字节,并使用X509Certificate2加载私钥

公共X509Certificate2(字节[]原始数据,字符串密码)

在Debug/Release中都可以在dev机器上正常工作,但是当部署到azure apps服务或构建机器时,我看到了“坏数据”错误

非常感谢您的帮助。
谢谢

您似乎想访问Azure app Service web app上应用程序的证书,您可以将证书上载到Azure网站中的证书集合,并从您网站的个人证书存储在您的web应用程序中使用它

上传证书

添加名为WEBSITE\u LOAD\u CERTIFICATES的应用程序设置,其值设置为证书的指纹

应用中的消费证书

X509Certificate2 retVal = null;

X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
certStore.Open(OpenFlags.ReadOnly);

X509Certificate2Collection certCollection = certStore.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, false);

if (certCollection.Count > 0)
{
    retVal = certCollection[0];
}

certStore.Close();

有关详细信息,请查看:

谢谢!,是的,我错过了这个重要的步骤,因为我似乎无法从我的嵌入式资源中读取.pfx文件,你能发布你的代码吗?如果必要的话,我可以问一个很好的问题没关系,让它工作吧