【问题标题】:wcf ssl client on other pc其他电脑上的 wcf ssl 客户端
【发布时间】:2023-03-30 08:37:01
【问题描述】:

我在服务器 PC 上的 WCF 中构建了一个 Web 服务。我创建了一个 https 端点并配置了一些本地证书。现在在网络上,我正在尝试创建一个 C# 控制台客户端来测试服务。但我收到此错误: 未处理的异常:System.ServiceModel.Security.SecurityNegotiationException: 调用方未通过服务进行身份验证。 ---> System.ServiceModel.FaultE xception:无法满足对安全令牌的请求,因为 authenti 阳离子失败。(以及更多)..

这里是我要连接的端点的代码:

http://pastebin.com/GGe6YaTb

这将是我的客户:

    <bindings>
        <wsHttpBinding>
            <binding name="WebDataServiceHttpBinding" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="TransportWithMessageCredential">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="true" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://anlocalip:9651/WebDataService" binding="wsHttpBinding"
            bindingConfiguration="WebDataServiceHttpBinding" contract="wcf1.IWebDataService"
            name="WebDataServiceHttpBinding">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

我无法摆脱这个错误,谁能帮帮我???

【问题讨论】:

    标签: c# wcf


    【解决方案1】:

    您可能需要在客户单元中安装/导入证书

    How can I install a certificate into the local machine store programmatically using c#?
    stackoverflow.com

    我有一个通过 MakeCert 生成的证书。我想使用 PeerTrust 将此证书用于 WCF 消息安全性。如何使用 c# 或 .NET 以编程方式将证书安装到“受信任的人”本地计算机证书存储中?


    Install certificates in to the Windows Local user certificate store in C#
    stackoverflow.com

    我正在编写一个 Windows 服务,它需要证书存储中的多个证书才能连接到第三方 Web 服务...


    使用证书保护服务

    How to: Secure a Service with an X.509 Certificate
    msdn.microsoft.com

    使用 X.509 证书保护服务是 Windows Communication Foundation (WCF) 中的大多数绑定使用的一项基本技术。本主题介绍了使用 X.509 证书配置自托管服务的步骤。

    【讨论】:

      【解决方案2】:

      尝试在打开代理之前设置模拟级别:

      serviceProxy.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
      serviceProxy.Open();
      

      【讨论】:

      • 不起作用,在客户端配置上我已将 更改为 然后我收到此错误..:Unhandled Exception:System.ServiceModel .FaultException :无法处理消息。这很可能是操作 'mynamespace/Login 不正确,或者因为消息包含无效或过期的安全上下文令牌,或者因为绑定之间不匹配。如果服务由于不活动而中止通道,则安全上下文令牌将无效。为了防止服务...等
      • 根据文档,HttpClientCredentialType 在 TransportWithMessageCredential 模式下被忽略。尝试先做一些更简单的工作,例如使用 ClientCredentialType="Basic" 进行传输安全
      • wcf 未提供用户名。在客户端凭据中指定用户名
      • 当然你必须在开启代理之前提供用户并通过serviceProxy.ClientCredentials.UserName并在你的服务行为中实现自定义UserNamePasswordValidator
      • 您是否坚持使用 Windows 凭据类型?否则,我可以向您展示如何使用 User/Pass 进行身份验证。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-19
      相关资源
      最近更新 更多