I have an C# windows application (.Net 3.0 Framework) that makes a call to PHP web service using HttpWebRequest
.
In Win 7 & Vista, if the call is
This error cropped up in a working C# application after migrating the website being accessed to a new server, and that indicated a server-side problem. Indeed, we finally resolved this issue by setting the "ServerName" value in the Apache configuration file to match the domain name registered in the certificate. (Another forum mentioned that setting "ServerAlias" would also work.)
More specifically, the httpd.conf file for the SSL site had the following in the VirtualHost section:
ServerName www.secure.mydomain.com
The certificate was registered to secure.mydomain.com
, and the URL we were accessing was also https://secure.mydomain.com/test.html
.
So simply changing the conf file to the following and restarting Apache did the trick:
ServerName secure.mydomain.com
The following would have also worked, most likely:
ServerName www.secure.mydomain.com
ServerAlias secure.mydomain.com
Here's some additional background information, for future reference:
The two errors we saw in the System.Net.trace.log were:
System.Net.Sockets Error: 0 : [4316] Exception in the
Socket#18796293::Receive - A blocking operation was
interrupted by a call to WSACancelBlockingCall
System.Net Error: 0 : [4316] Exception in the
HttpWebRequest#35191196:: - The operation has timed out
Here are all the things we tried which did not resolve the issue:
The https URL could be opened in Opera, IE8, and Firefox without any problems. WGET for Windows complained about an invalid certificate, but then again, WGET is an old application and does not appear to trust as many certificates.
The C# client application worked under Windows XP, but not in Windows 7 or Windows Vista. It appears that Windows 7 and Vista are more aggressive about validating the certificate. They do not provide an informative error message when it fails, and instead simply time out during the SSL handshake.