c# – 对SSPI的调用失败,第二次运行调用时会看到内部异常吗?

c# – 对SSPI的调用失败,第二次运行调用时会看到内部异常吗?,第1张

概述我有以下代码: public GetUserDataResponse GetUserDataFromService(X509Certificate2 certificate){ ChannelFactory<MyApp4SITHSService.IMyApp4SITHSServiceContract> factory = new ChannelFactory<MyApp4SITHSSer 我有以下代码:

public GetUserDataResponse GetUserDataFromService(X509Certificate2 certificate){    ChannelFactory<MyApp4SITHSService.IMyApp4SITHSServiceContract> factory = new ChannelFactory<MyApp4SITHSService.IMyApp4SITHSServiceContract>("NetTcpBinding_IMyApp4SITHSServiceContract_Certificate");    MyApp4SITHSService.IMyApp4SITHSServiceContract service;    GetUserDataResponse response;    factory.Credentials.ClIEntCertificate.Certificate = certificate;    //factory.Credentials.Username.Username = "me";    //factory.Credentials.Username.Password = "password";    service = factory.CreateChannel();    LogHandler.Writeline("Connecting to service");    response = service.GetUserData(new GetUserDataRequest());    LogHandler.Writeline("Data received");    factory.Abort();    return response;}

我第一次运行它时效果很好,第二次在service.GetUserData上得到以下异常:

A first chance exception of type ‘System.ServiceModel.Security.SecurityNegotiationException’ occurred
in mscorlib.dll

A call to sspI Failed,see inner exception.

The Local Security Authority cannot be contacted

我使用以下配置:

<system.serviceModel>  <behaviors>    <endpointBehaviors>      <behavior name="CertificateEndpointBehavior">        <clIEntCredentials>          <!--<clIEntCertificate findValue="MyAppClIEnt" x509FindType="FindBySubjectname" storeLocation="CurrentUser" storename="TrustedPeople"/>-->          <!--<clIEntCertificate findValue="MyAppClIEnt" x509FindType="FindBySubjectname" storeLocation="LocalMachine" storename="My"/>-->          <serviceCertificate>            <authentication certificateValIDationMode="ChainTrust" revocationMode="NoCheck"/>          </serviceCertificate>        </clIEntCredentials>      </behavior>    </endpointBehaviors>  </behaviors>    <bindings>        <netTcpBinding>            <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 mode="Transport">                    <transport clIEntCredentialType="Certificate" />                    <message clIEntCredentialType="Certificate" />                </security>            </binding>        </netTcpBinding>    </bindings>    <clIEnt>        <endpoint address="net.tcp://localhost:8135/MyApp4SITHSService/ClIEnt/sll"            behaviorConfiguration="CertificateEndpointBehavior" binding="netTcpBinding"            bindingConfiguration="netTcpCertificate" contract="MyApp4SITHSService.IMyApp4SITHSServiceContract"            name="NetTcpBinding_IMyApp4SITHSServiceContract_Certificate">            <IDentity>                <dns value="MyAppServer" />            </IDentity>        </endpoint>    </clIEnt></system.serviceModel>

知道我为什么会遇到这个问题以及如何解决它?

解决方法 服务器无权联系本地计算机证书存储区以验证传入证书的信任 总结

以上是内存溢出为你收集整理的c# – 对SSPI的调用失败,第二次运行调用时会看到内部异常吗?全部内容,希望文章能够帮你解决c# – 对SSPI的调用失败,第二次运行调用时会看到内部异常吗?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1218779.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-05
下一篇 2022-06-05

发表评论

登录后才能评论

评论列表(0条)

保存