Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.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# 为什么在使用消息安全性时获得WindowsIdentity?_C#_.net_Wcf_Security_Windows Identity - Fatal编程技术网

C# 为什么在使用消息安全性时获得WindowsIdentity?

C# 为什么在使用消息安全性时获得WindowsIdentity?,c#,.net,wcf,security,windows-identity,C#,.net,Wcf,Security,Windows Identity,从无安全性切换到证书时,我在IAuthorizationPolicy中获得WindowsIdentity。Evaluate evaluationContext.Properties.TryGetValueIdentifications,out obj?这是否出于设计: 由此: <binding name="NetTcpBinding_IMyAppClientServiceRegular" closeTimeout="00:01:00" openTimeout="00:01:00" rece

从无安全性切换到证书时,我在IAuthorizationPolicy中获得WindowsIdentity。Evaluate evaluationContext.Properties.TryGetValueIdentifications,out obj?这是否出于设计:

由此:

<binding name="NetTcpBinding_IMyAppClientServiceRegular" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="infinite" sendTimeout="01:00:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
          <reliableSession ordered="true" inactivityTimeout="infinite" enabled="false"/>
          <security mode="None">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
为此:

<binding name="netTcpCertificate" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="infinite" sendTimeout="01:00:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="1000" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="200" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
          <reliableSession ordered="true" inactivityTimeout="infinite" enabled="false"/>
          <security>
            <message clientCredentialType="Certificate"/>
          </security>
        </binding>
是否有任何方法可以避免在IAuthorizationPolicy.Evaluate中获取WindowsIdentity?我只希望在使用此绑定时设置WindowsIdentity:

<binding name="NetTcpBinding_IMyAppClientServiceWindows" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="infinite" sendTimeout="01:00:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
          <reliableSession ordered="true" inactivityTimeout="infinite" enabled="false"/>
          <security mode="Message">
            <message clientCredentialType="Windows"/>
          </security>
我注意到您没有在netTcpCertificate配置中设置模式,而不是您可能需要的模式:。通过不设置mode属性,WCF将使用of传输而不是消息,这可能是您想要的证书凭据。当模式设置为传输时,WCF可能正在传递Windows标识,但我还没有尝试验证它

更新:
根据下面的注释,您应该确保客户端配置文件endpoint>indentity>dns>值与服务器证书CN=value的名称匹配。此值需要根据您输入的内容设置为MyAppServer。

Hi,将其设置为mode=消息IAAuthorizationPolicy.Evaluate将不会触发=未登录。不过,服务方法已执行,但返回时将引发以下异常:传出消息的标识检查失败。远程终结点的预期DNS标识为“localhost”,但远程终结点提供了DNS声明“MyAppServer”。我认为它使用的是消息,因为您看到的错误是由于证书未使用localhost作为域名DNS标识。但是,将mode属性保留为空可能是正确的。查看证书的消息安全性。首先尝试让该示例在wsHttpBinding中成功运行。接下来,将示例绑定示例更改为使用netHttpBinding并使其正常工作。最后,用示例检查配置。什么属性应该为空?我遵循了这个示例,这正是我所需要的:它使用对等信任而不是链,它也使用TCP而不是wsHTTP。我指的是配置中的安全元素。我已经编辑了答案。