[Mono-list] Accessing secure site: x509 + basic authentication

Quintin Oliver quintin@billinglive.com
Tue, 02 Nov 2004 09:02:07 +0000


Hi,

I'm attempting to access a secured site using Mono, the site uses
certification (https) and basic authentication.  When running my code I'm
given the result:

Error getting response stream: ReceiveFailure

After various attempts I decided to test the same code on SharpDevelop
with the MS Framework v1.1, this compiled fine and works (ie I get the
correct response from the server).  This suggests to me that the code is
fine however it's a bug relating to Mono?? Or am I deluding myself :S

The code doesn't get as far as 'Console.WriteLine("Got Response");'

Any advice appreciated!

<< Code Snippet >>

// Service Point
ServicePointManager.CertificatePolicy = new MyPolicy();
	
HttpWebRequest webRequest = (HttpWebRequest)
HttpWebRequest.Create("https://www.securesite.com/login");

// Crendential Cache
credentialcache.Add(new Uri("https://www.securesite.com/login"), "Basic",
new System.Net.NetworkCredential("user", "password"));

webRequest.Credentials = crendentialcache;
			
			X509Certificate x509 =
X509Certificate.CreateFromCertFile("/cert/mycert.cer");
			webRequest.ClientCertificates.Add(x509);
			
			System.Net.HttpWebResponse response = (HttpWebResponse)
webRequest.GetResponse();
			
			Console.WriteLine("Got GetResponse");



			System.IO.StreamReader reader = new
StreamReader(response.GetResponseStream());

			string HTML = reader.ReadToEnd();
			
			Console.WriteLine(responseHTML);
			
			response.Close();

			reader.Close();