C# Web Service Call (asmx) over SSL with wildcard certificate
|August 21, 2014||Posted by forumadmin under TechQns||
I am making a web service call from a windows service. The web service is to use SSL so the url to the webservice is https://myclient.mydomain.com:4443/app/webservices/webservice.asmx
4443 is being used instead of 443 for other reasons.
I can browse to this URL and it works fine. The certificate is purchased from GlobalSign and is a wildcard certificate *.mydomain.com
There are no issues browsering to the webservice.
When I make the call from the windows service it’s not working. Using System.Net.Trace I was able to get the below information. While browsers work fine it seems .NET doesn’t work correctly with wildcard certificates. Has anyone else experienced this?
[Subject] CN=*.mydomain.com, OU=Domain Control Validated Simple Name: *.mydomain.com DNS Name: mydomain.com [Issuer] CN=AlphaSSL CA - G2, O=AlphaSSL Simple Name: AlphaSSL CA - G2 DNS Name: AlphaSSL CA - G2 System.Net Information: 0 :  SecureChannel#48611003 - Remote certificate has errors: ProcessId=8676 DateTime=2014-08-21T20:58:13.4998725Z System.Net Information: 0 :  SecureChannel#48611003 - Certificate name mismatch. ProcessId=8676 DateTime=2014-08-21T20:58:13.4998725Z System.Net Information: 0 :  SecureChannel#48611003 - Remote certificate was verified as invalid by the user. ProcessId=8676 DateTime=2014-08-21T20:58:13.4998725Z System.Net.Sockets Verbose: 0 :  Socket#31879635::Dispose() ProcessId=8676 DateTime=2014-08-21T20:58:13.4998725Z System.Net Error: 0 :  Exception in HttpWebRequest#10189992:: - The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.. ProcessId=8676 DateTime=2014-08-21T20:58:13.4998725Z
– UPDATE 1 –
Ok partically resolved. I had forgotten we put in code to convert all host names to IP addresses which was causing the name mismatch. This url https://connect.microsoft.com/VisualStudio/feedback/details/872612/net-web-service-call-stuck-in-infinite-loop-due-to-exception-in-system-net-sockets describes why we did this because of errors in .NET we were gettin when windows is set to IPv6 preferred.
I’ve removed this host name to IP address conversion but now it won’t connect at all now and am getting System.Net.Sockets Error: 0 :  Exception in Socket#31879635::EndConnect – A socket operation was attempted to an unreachable network 18.104.22.168:4443. even though the connection attempt it to the url with the host name and we can browse from the machine to that ip and host name url with a browser.
– UPDATE 2 –
Now determined works ok on Windows 7 but not working with Windows 8.1 getting the socket operation error. Funny part the Windows 7 is a VM running on the Windows 8.1 machine.
|Asked By – Chris Ward||Read Answers|