You will need that code added if the server has a certificate, otherwise your code will not verify the servers certificate.
What happens if you make the same request again after getting the first Response? Sounds like you're getting an initial "logged on" response, so what happens if you then just re-request the file? Dino -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Eddie Lascu Sent: Thursday, 12 July 2007 03:46 To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] Accessing files over HTTPS -> for Dean Cleaver Hi Dean, No, that did not make a difference. I think I am OK with getting authenticated in the server. It's the file access part that is not OK. Thanks anyway for your time. Regards, Eddie -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] Behalf Of Dean Cleaver Sent: Tuesday, July 10, 2007 2:14 PM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] Accessing files over HTTPS -> for Peter Ritchie Ok - that is a client certificate for sure. I've got code that issues an HTTPS post to a remote server using client certificates, but nothing that retrieves a file from the remote server using client certificates - only using server certificates. With your original code posted earlier today, add this just after creating your HttpWebRequest: ServicePointManager.ServerCertificateValidationCallback = this.ValidateServerCertificate; And then add this code: public bool ValidateServerCertificate( object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { if (sslPolicyErrors == SslPolicyErrors.None) return true; // Do not allow this client to communicate with unauthenticated servers. return false; } See if that helps. Dino -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Eddie Lascu Sent: Wednesday, 11 July 2007 06:03 To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] Accessing files over HTTPS -> for Peter Ritchie Yes, it does and I have to select the certificate they gave me and I installed on my client machine. If I select something else or do not select anything at all will not connect to the remote server. -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] Behalf Of Dean Cleaver Sent: Tuesday, July 10, 2007 1:39 PM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] Accessing files over HTTPS -> for Peter Ritchie Eddie, If you try to retrieve the file in your browser, does it ask you to pick a client certificate from a list? I know in the other situation I have where I access a remote server with a client certificate, that's exactly what happens via IE7. Dino -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Eddie Lascu Sent: Wednesday, 11 July 2007 04:55 To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] Accessing files over HTTPS -> for Peter Ritchie Hello Dean, I just entered this fascinating world and I am completely inexperienced. I really don't know what is the difference between a server certificate and a client certificate. Given that I had to install the digital certificate on my client machine (although the certificate was provided by the company that hosts the server I am trying to access) my guess is that it is a client certificate. In my case I am trying to implement an automated process, w/o human intervention. There should be no login step and I believe that is why I was presented with the digital certificate I had to install. Thanks, Eddie -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] Behalf Of Dean Cleaver Sent: Tuesday, July 10, 2007 12:36 PM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] Accessing files over HTTPS -> for Peter Ritchie Eddie, Can you clarify - are you using a server certificate (standard https) or are you using a client certificate? The code below appears as if you're using a client certificate. I retrieve files over HTTPS with just a server certificate like this: public static bool Retrieve(string url, string userName, string password, string fileName) { WebClient client = new WebClient(); client.Credentials = new NetworkCredential(userName, password); ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate; try { client.DownloadFile(url, fileName); return true; } catch { return false; } } public static bool ValidateServerCertificate( object sender, X509Certificate certificate, X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) { if (sslPolicyErrors == System.Net.Security.SslPolicyErrors.None) return true; Console.WriteLine("Certificate error: {0}", sslPolicyErrors); // Do not allow this client to communicate with unauthenticated servers. return false; } In my case, I have to log into the remote server as well, hence the username, password and the NetworkCredential - you can remove those if the remote server is not protected. Cheers, Dino =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor. http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor. http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com