0
votes

I'm trying to make a soap client in VisualStudio. First thing I've done was generating proxy class with delivered WSDL file (using Add Service Reference option in VisualStudio). It was generated with wrong binding configuration - message security should be:
DefaultAsymmetricSignatureAlgorithm - "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" DefaultCanonicalizationAlgorithm - "http://www.w3.org/2001/10/xml-exc-c14n#" and DefaultDigestAlgorithm - "http://www.w3.org/2001/04/xmlenc#sha256",

while it is: DefaultAsymmetricSignatureAlgorithm "http://www.w3.org/2000/09/xmldsig#rsa-sha1" DefaultCanonicalizationAlgorithm "http://www.w3.org/2001/10/xml-exc-c14n#" and DefaultDigestAlgorithm "http://www.w3.org/2000/09/xmldsig#sha1".

I tried changing basicHttpBinding settings in App.conf by adding:

<security mode="Message">
            <message algorithmSuite="Basic256Sha256" clientCredentialType="Certificate"/>
</security>

and certificate:

var cert = new X509Certificate2(AppDomain.CurrentDomain.BaseDirectory + "//cert.p12", "Pass");
client.ChannelFactory.Credentials.ClientCertificate.Certificate = cert;
client.ClientCredentials.ClientCertificate.Certificate = cert;

But I got the exception:

The service certificate is not provided for target 'http://.../service'. Specify a service certificate in ClientCredentials.

But I don't think I have a service certificate at all (service belongs to another company). I tried using the same certificate for ClientCertificate and ServiceCertificate.

client.ClientCredentials.ServiceCertificate.DefaultCertificate = cert;

But I got error :The certificate that was used has a trust chain that cannot be verified. Replace the certificate or change the certificateValidationMode.

Changing mode to None gives excepion Security not found.

In general, sending request using SoupUI works fine, but I can't make right configuration in my client service to send any request.

1

1 Answers

0
votes

I suppose to you use self-signed cert.WCF will verify all the chain of issuers and expects that finally chain would end on root trusted authority.You can add the line below to app.config to disable the check.However, it is best not to use in production : serviceBehaviors/behavior/serviceCredentials/clientCertificate.

<authentication certificateValidationMode="PeerOrChainTrust" revocationMode="NoCheck" />