简体   繁体   English

Request.GetClientCertificate 有时会在 Web API 中返回不正确的信息

[英]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.

相关问题 HttpRequestMessage.GetClientCertificate() 在 Web API 中返回 null - HttpRequestMessage.GetClientCertificate() returns null in Web API 处理较大负载的PUT / POST请求时,C#request.GetClientCertificate()冻结 - C# request.GetClientCertificate() freezes when processing PUT/POST request with larger payload 元数据有时会返回完全不正确的创建日期 - Metadata Sometimes Returns Completely Incorrect Date Created 使用Windows证书注册API创建证书请求将返回错误“参数不正确。 0x80090027” - Creating a certificate request with the Windows Certificate Enrollment API returns error “The parameter is incorrect. 0x80090027” 在ASP.NET Web API 2中,ByteRangeStreamContent与Azure存储中的流一起使用时返回不正确的数据 - In ASP.NET Web API 2, ByteRangeStreamContent returns incorrect data when used with a stream from Azure Storage Web API POST 请求返回 500 错误,GET 请求在 Azure 上返回 200 OK - Web API POST Request returns 500 Error, GET Request returns 200 OK on Azure 为什么 Application.Selection.Range.Start 有时会返回不正确的值? - Why Application.Selection.Range.Start returns incorrect value sometimes? 在不正确的数据类型 WCF Web API 上返回错误请求 (HTTP 400) 错误 - Returning Bad Request (HTTP 400) errors on incorrect data types WCF Web API Web API返回null - Web API returns null 使用时刻和 web api 请求使用 .net 核心的日期格式不正确 - Incorrect date format using moment and web api request using .net core
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM