证书(PFX文件)的作品在code,但从ASP网的Web应用程序主机后不工作 [英] Certificate (pfx file) works in code but not working after Hosting from ASP Net web application

查看:105
本文介绍了证书(PFX文件)的作品在code,但从ASP网的Web应用程序主机后不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要验证 PFX 文件,并从网络基础应用获得证书的详细信息
但它不是在 IIS托管页面后工作,只在单机​​上工作。

I have to verify the pfx file and get certificate details from the web base application but its not working after hosting the page in IIS, It only work on single machine.

- 首先创建一个exe为获取详细信息,但仍然它不工作,

-First I create an exe for the fetching the details but still its not working,

(exe文件保存在一个表中的响应。
我们希望获取在Web应用程序的响应。
它正在通过code,但托管这是行不通的了。)

(exe saves the response in one table. And we want to fetch the response in the web Application. It is working through Code But After Hosting this is not working.)

我是通过创建批处理文件获取数据。

I am fetching the data through creating the batch files.

这样的:

请给我如何从exe文件获取数据到Web应用程序的任何建议或意见。
可以任何一个有想法,请告诉我。

Please give me any suggestion or Idea for how to get the data from exe to web application. can any one have idea please tell me.

感谢。

推荐答案

在.NET证书加载绑定到用户配置文件和证书存储 - 即使证书是从文件中加载。当在托管环境加载一些特殊的标志需要添加:

The certificate loading in .NET is tied to the user profile and certificate store - even though the certificate is loaded from file. When loading in a hosting environment some special flags need to be added:

// The X509KeyStorageFlags.MachineKeySet flag is required when loading a
// certificate from file on a shared hosting solution such as Azure.
private static readonly X509Certificate2 signingCertificate =
  new X509Certificate2(HttpContext.Current.Server.MapPath(
  "~\\App_Data\\Kentor.AuthServices.StubIdp.pfx"), "",
  X509KeyStorageFlags.MachineKeySet);

Exampel从<一个href=\"https://github.com/KentorIT/authservices/blob/master/Kentor.AuthServices.StubIdp/Models/AssertionModel.cs\" rel=\"nofollow\">https://github.com/KentorIT/authservices/blob/master/Kentor.AuthServices.StubIdp/Models/AssertionModel.cs

这篇关于证书(PFX文件)的作品在code,但从ASP网的Web应用程序主机后不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆