title: C# Web Service Call (asmx) over SSL with wildcard certificate
body: <p>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 <a href="https://myclient.mydomain.com:4443/app/webservices/webservice.asmx" rel="nofollow">https://myclient.mydomain.com:4443/app/webservices/webservice.asmx</a></p>
  
  <p>4443 is being used instead of 443 for other reasons.</p>
  
  <p>I can browse to this URL and it works fine.  The certificate is purchased from GlobalSign and is a wildcard certificate *.mydomain.com</p>
  
  <p>There are no issues browsering to the webservice.</p>
  
  <p>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?</p>
  
  <pre><code>[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 : [2688] SecureChannel#48611003 - Remote certificate has errors:
      ProcessId=8676
      DateTime=2014-08-21T20:58:13.4998725Z
  
  System.Net Information: 0 : [2688] SecureChannel#48611003 -     Certificate name mismatch.
      ProcessId=8676
      DateTime=2014-08-21T20:58:13.4998725Z
  
  System.Net Information: 0 : [2688] 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 : [2688] Socket#31879635::Dispose()
      ProcessId=8676
      DateTime=2014-08-21T20:58:13.4998725Z
  
  System.Net Error: 0 : [2688] 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
  </code></pre>
  
  <p>-- UPDATE 1 --</p>
  
  <p>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 <a href="https://connect.microsoft.com/VisualStudio/feedback/details/872612/net-web-service-call-stuck-in-infinite-loop-due-to-exception-in-system-net-sockets" rel="nofollow">https://connect.microsoft.com/VisualStudio/feedback/details/872612/net-web-service-call-stuck-in-infinite-loop-due-to-exception-in-system-net-sockets</a> describes why we did this because of errors in .NET we were gettin when windows is set to IPv6 preferred.</p>
  
  <p>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 : [5788] Exception in Socket#31879635::EndConnect - A socket operation was attempted to an unreachable network 173.78.224.118: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.</p>
  
  <p>-- UPDATE 2 --</p>
  
  <p>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.</p>