【问题标题】:how to add basicHttpBinding to the custombinding code如何将 basicHttpBinding 添加到自定义绑定代码
【发布时间】:2019-06-10 20:53:50
【问题描述】:

我需要使用 WCF 配置文件中的证书对端点进行身份验证 我尝试使用各种 authenticationMode 设置添加 但它不适用于customBinding 你能帮我把下面的代码转换成自定义绑定吗

        <basicHttpBinding>
            <binding name="certBinding">
                <security mode="Message">
                    <message clientCredentialType="Certificate" />
                </security>
            </binding>
        </basicHttpBinding>

这是我在自定义绑定中尝试过的代码

<customBinding>
        <binding name="OutbBinding1" closeTimeout="00:02:00" openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02:00">
                    <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap11" writeEncoding="utf-8">
                        <readerQuotas maxDepth="32" maxStringContentLength="20000000" maxArrayLength="20000000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    </textMessageEncoding>
            <security authenticationMode="SecureConversation">
            <secureConversationBootstrap authenticationMode="AnonymousForCertificate" />
            </security>
    </binding>
</customBinding>

【问题讨论】:

    标签: wcf web-config


    【解决方案1】:

    众所周知,如果我们使用BasicHttpbinding的消息安全,我们应该在客户端和服务器端都设置证书。此外,我们还应该在服务器和客户端之间建立证书信任关系。
    还有一点需要注意的是,与传输层安全的认证方式不同,我们需要在客户端设置一个默认的服务证书(非客户端证书,使用受信任的服务器证书来签署消息)。
    因此,无论如何,下面的配置可以实现使用证书对客户端进行身份验证的相同目标。请参考以下配置。

    <customBinding>
        <binding name="TehRealBinding">
            <textMessageEncoding />
            <security authenticationMode="MutualCertificate" />
            <httpTransport />
        </binding>
    </customBinding>
    

    此外,以下文档可能对您有用。
    https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/securitybindingelement-authentication-modes
    如果有什么可以帮助您的,请随时告诉我。

    【讨论】:

    • 感谢您的回复,我已尝试使用 MutualCertificate,但它不起作用。当我通过浏览器调用端点 HTTPS url 时,它工作正常,(Web 浏览器页面属性显示“TLS 1.2,AES 与 256 位加密(高);ECDH_P256 与 256 位交换”)需要在以上绑定使这项工作,我尝试了几乎所有的身份验证模式都没有工作,请帮助我
    • 在您使用您的costom绑定使用证书对客户端进行身份验证之前,我建议您先完成以下官方示例。 docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/…
    • 证书可能有问题,我们可以通过IIS服务证书模块为测试创建一个证书。
    • 请先建立信任关系,然后在调用服务时提供服务证书和客户端证书。
    猜你喜欢
    • 1970-01-01
    • 2011-08-27
    • 1970-01-01
    • 1970-01-01
    • 2021-02-13
    • 2013-11-07
    • 2016-05-21
    • 1970-01-01
    • 2016-09-18
    相关资源
    最近更新 更多