Undoubtedly, you just need to work a bit to get started with a custom security binding extension element for describing tokens and which you need to use for signing / support. For purposes of clarification, I assume that you always want both the certificate and username / password to be transferred.
TransportSecurityBindingElement . : SignedEncrypted, Signed Endorsing. , , UserNameSecurityTokenParameters SignedEncrypted X509SSecurityTokenParameters Endorsing. , / , /, / . :
public class MySecurityBindingElement : BindingElementExtensionElement
{
public override void ApplyConfiguration(BindingElement bindingElement)
{
base.ApplyConfiguration(bindingElement);
TransportSecurityBindingElement transportSecurityBindingElement = (TransportSecurityBindingElement)bindingElement;
transportSecurityBindingElement.EndpointSupportingTokenParameters.SignedEncrypted.Add(new UserNameSecurityTokenParameters());
transportSecurityBindingElement.EndpointSupportingTokenParameters.Endorsing.Add(new X509SecurityTokenParameters
{
InclusionMode = SecurityTokenInclusionMode.AlwaysToRecipient,
ReferenceStyle = SecurityTokenReferenceStyle.Internal,
RequireDerivedKeys = false,
X509ReferenceStyle = X509KeyIdentifierClauseType.Any
});
}
protected override BindingElement CreateBindingElement()
{
TransportSecurityBindingElement result = new TransportSecurityBindingElement
{
IncludeTimestamp = true,
LocalClientSettings.DetectReplays = false,
LocalServiceSettings.DetectReplays = false
};
this.ApplyConfiguration(result);
return result;
}
}
, , , , , . , Credentials ChannelFactory, WCF, ClientBase proxy. , , - , :
<endpointBehavior>
<behavior name="MyBehavior">
<clientCredentials>
<clientCertificate findValue="MySubject" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My" />
</clientCredentials>
</behavior>
</endpointBehavior>
, / .
, STS , OperationContext::SupportingTokens. UserNameSecurityToken X509SecurityToken , .