我正在将我的应用程序从 .net Framework 转换为 .net core 2.1。现在我面临两个问题
1)在.net框架中我们可以使用
HttpClientCertificate cert = Request.ClientCertificate;
那么我们如何在.net core中使用Request.ClientCertificate。
2)在.net框架中,我们可以设置位置配置,如
<location path="MyPath">
<system.webServer>
<security>
<access sslFlags="Ssl.SslRequireCert,SslNegotiateCert,Ssl128" />
</security>
</system.webServer>
</location>
我想在网络核心中使用
<access sslFlags="Ssl.SslRequireCert,SslNegotiateCert,Ssl128" />
。我该如何做这两件事。有什么帮助吗?
要访问客户端证书,您可以:
要使用 sslFlags,您必须将其添加到 web.config 文件中(与标准 .NET Framework 完全相同)。发布应用程序后,webconfig 文件会自动生成。打开它后,您可以添加
访问 sslFlags:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\IdentityServer4Demo.dll" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" />
</system.webServer>
</location>
<location path="account">
<system.webServer>
<security>
<access sslFlags="Ssl,SslNegotiateCert,SslRequireCert" />
</security>
</system.webServer>
</location>
<system.webServer>
<security>
<access sslFlags="SslNegotiateCert" />
</security>
</system.webServer>
</configuration>
在 IIS 7 及以上版本中未修改访问元素
https://learn.microsoft.com/enus/iis/configuration/system.webserver/security/access