[英]Request.GetClientCertificate sometimes returns incorrect information in Web API
I have a.Net 4.6 Web Application running on IIS which reads smart cards to get user information.我有一个运行在 IIS 上的.Net 4.6 Web 应用程序,它读取智能卡以获取用户信息。 In the beginning the application was working fine but after a few days other user's card information was showing up for different users.一开始,该应用程序运行良好,但几天后,其他用户的卡信息显示给不同的用户。 For example someone nowhere near me or associated with me tried to login but my smart card information would show up as though it was read from their card.例如,远离我或与我有关联的人试图登录,但我的智能卡信息会显示为好像是从他们的卡中读取的一样。 It is almost like my smart card information is being cached on the server.几乎就像我的智能卡信息被缓存在服务器上一样。
This is the code that reads the smart card information.这是读取智能卡信息的代码。
X509Certificate2 clientCert = new X509Certificate2(Request.GetClientCertificate());
u.Info = clientCert.Subject.ToString();
I just found out that if I restart IIS the credential that was showing will reset and the correct one will show.我刚刚发现,如果我重新启动 IIS,则显示的凭据将重置并显示正确的凭据。
Not sure what I am doing wrong that I am not getting the correct smart card information.不知道我做错了什么,我没有得到正确的智能卡信息。
Thanks!!谢谢!!
The problem ended up being a static variable.问题最终成为 static 变量。
Static variables creates a single instance of a variable that is accessible by every application user. Static 变量创建每个应用程序用户都可以访问的变量的单个实例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.