Getting WCF service (host / client) to work with https on Linux using Mono

I have a small test console application that serves as a WCF host and another console application that serves as a client.

The client can reach the host via http, everything works fine. But when switching to https, I get the following error:

Error: System.Net.WebException: Error: SendFailure (Error writing headers) --->
System.Net.WebException: Error writing headers --->
System.IO.IOException: The authentication or decryption has failed. --->
Mono.Security.Protocol.Tls.TlsException: The authentication or decryption has failed.
...

      

Actions taken so far, I tried to solve the problem:

  • I have verified that the ca-certificates-mono package is installed
  • I imported the CA certificates into the machine store (why do I need this if I'm working with a self-signed certificate?)

    sudo mozroots --import --machine --sync

  • I created a self-configuring certificate for testing (as described in the FAQ)

    makecert -r -eku 1.3.6.1.5.5.7.3.1 -n "CN=Cert4SSL" -sv cert.pvk cert.cer

  • I added it to the mono cert repository

    sudo certmgr -add -c -m Trust cert.cer

    I also ran tests with other stores (Root, My) and also using not processing but in the user store - none worked, same error on every try

  • I assigned the port that my service uses for the certificate

    httpcfg -add -port 6067 -cert cert.cer -pvk cert.pvk

  • I added that ignoring certificate validation

    ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true;

    It didn't help either (but it got called, the cert object looked completely in the debugger).

The client uses this code to call the WebService:

IService svcClient2 = null;
string address2 = "https://localhost:6067/TestService";
BasicHttpBinding httpBinding2 = new BasicHttpBinding();
httpBinding2.TransferMode = TransferMode.Buffered;
httpBinding2.Security.Mode = BasicHttpSecurityMode.Transport;
httpBinding2.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
httpBinding2.MessageEncoding = WSMessageEncoding.Text;
httpBinding2.UseDefaultWebProxy = true;
ChannelFactory<IService> channelFac2 = new ChannelFactory<IService>( httpBinding2, new EndpointAddress( address2 ) );
svcClient2 = channelFac2.CreateChannel();
string res2 = svcClient2.TestHello( "Bob" );   // <----- this is where I get the exception

      

Any help is appreciated, I feel like running in a circle.

Some information about environment: I am using Ubuntu 14.04 LTS and Mono 4.0.2, IDE is MonoDevelop

edit: I have now created the same projects with visual studio and C #, it works there as expected. The client can connect to the host on both http and https. If I copy the mono version to my Windows machine, I run the same problem and error message as on Ubuntu.

Could this be a singly linked problem?

+3


source to share





All Articles