我的站点调用一个需要一组非常复杂的身份验证协议的服务(我们称之为FooService)。所有协议都封装在自定义ClientCredentials行为中,该行为在代码中声明如下:
class FooServiceCredentialsBehavior : ClientCredentials
{
public FooServiceCredentialsBehavior()
{
//Set up service certificate
var cert = CertStore.FindBySerialNumber(certSerialNumber);
base.ServiceCertificate.DefaultCertificate = cert;
}
}
然后注册行为扩展:
<behaviorExtensions>
<add name="FooServiceCredentials" type="MyProject.Namespace.FooService, MyProject" />
</behaviorExtensions>
配置endpointBehavior以使用它:
<endpointBehaviors>
<behavior name="FooServiceCredentialsBehavior">
<FooServiceCredentials />
</behavior>
并设置端点以使用它:
<endpoint address="https://fooservice.com/bar"
behaviorConfiguration="FooServiceCredentialsBehavior"
contract="FooService_PortType" />
以上各项工作完美,多年来为众多客户服务。
我无法修改FooServiceCredentials类
base.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
但我不能。
我想知道是否有可能添加WCF配置,这是适用于自定义凭据行为,将做同样的事情。像这样:
<endpointBehaviors>
<behavior name="FooServiceCredentialsBehavior">
<FooService>
<ServiceCertificate>
<authentication certificateValidationMode="None"/>
</ServiceCertificate>
</FooService>
</behavior>
有可能吗?怎么用?