L
L
Lion66662017-10-04 14:22:17
.NET
Lion6666, 2017-10-04 14:22:17

Connecting to a WCF service, Security block. What is the problem?

Good day to all. I'm trying to connect to a WCF service using the WS-Security standard. A certificate is used to sign requests:

<clientCredentials>
    <clientCertificate x509FindType="FindBySubjectName"
                       storeLocation="CurrentUser"
                       storeName="My"
                       findValue="Тестовый НБКИ - 2016-07"/>
    <serviceCertificate>
        <authentication certificateValidationMode="None" />
    </serviceCertificate>
</clientCredentials>

Here is the connection point itself:
<endpoint address="https://ips.rosminzdrav.ru/5358bf30e7897"
   behaviorConfiguration="ipsErBeh" binding="wsHttpBinding" bindingConfiguration="newBinding"
   contract="ipsWorkMisService.misInterface" name="ipsWorkEndPoint"/>

And the binding used:
<wsHttpBinding>
    <binding name="newBinding" maxReceivedMessageSize="2147483647"
             messageEncoding="Text">
        <security mode="TransportWithMessageCredential"> 
            <message clientCredentialType="Certificate" />
        </security>
    </binding>
</wsHttpBinding>

The necessary things are thrown into the Security block:
ipsWorkMisService.misInterfaceClient ms = new misInterfaceClient("ipsWorkEndPoint");

if (security != null)
{
    X509SecurityTokenParameters tokenParameters = new X509SecurityTokenParameters();
    tokenParameters.InclusionMode = SecurityTokenInclusionMode.AlwaysToRecipient;
    tokenParameters.RequireDerivedKeys = false;
    security.EndpointSupportingTokenParameters.SignedEncrypted.Add(tokenParameters);
    security.EndpointSupportingTokenParameters.SignedEncrypted.Add(new UserNameSecurityTokenParameters());
}
ms.Endpoint.Binding = new CustomBinding(elements.ToArray());

But when trying to connect, the server gives an error "Checking the security block: header\TransportHeader element not found". Please advise: what could be wrong? The header element is in place, as far as I understand. Thanks in advance for your replies!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur, 2017-10-04
@OrenTiger

Try changing the configuration of the security element to:

<security mode="Transport">  
  <transport clientCredentialType="Certificate"/>
</security>

See link: Transport Security with Certificate Authentication

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question