function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
HANS YADAVHANS YADAV 

System.Net.WebException: The underlying connection was closed:

Hi all,
When i login to the SFDC i get this error very frequently "System.Net.WebException: The underlying connection was closed: Could not establish secure channel for SSL/TLS." Please help me, this is urgent.

Regards
Hans
BrianO'HalloranBrianO'Halloran
This is a new error popping up for me as well

System.Net.WebException: The underlying connection was closed: Could not establish secure channel for SSL/TLS. ---> System.ComponentModel.Win32Exception: The message or signature supplied for
benjasikbenjasik
Thanks, we'll look into this as well
jvjv
Me too.. VS 2005, C#

Error: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel..

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Salesforce_SLA_Verification {

	public partial class Form1 : Form {
		public Form1() {
			InitializeComponent();
		}

		//private SforceService binding = null;
		private sForce.LoginResult loginResult = null;
		private String un = "foo@asdfasdfasdfasdfadf.com";    
devNut!devNut!
Hi benjasik,

Have you determined why this error is occuring?
I am currently getting the same error described above.

Thanks!
smithsmith

I am also getting the same thing.

But the strang thing is when I execute the code in DEBUG mode, it works fine. If I execute the exe, it gives me the error.

"The underlying connection as closed: Could not establish secure channel for SSL/TLS"

smithsmith

Hey, I got it resolved.

write the below code in ur webservice code (reference.as/vb)

protected override System.Net.WebRequest GetWebRequest(Uri uri)
  {
   System.Net.HttpWebRequest webRequest =  (System.Net.HttpWebRequest) base.GetWebRequest(uri);
   webRequest.KeepAlive = false;
   return webRequest;
  }

Hope, this works!!!

Smith

jvjv
I had forgotten about this thread until somebody posted to it.

My C# code is working...

                sForce.LoginResult loginResult = null;

                // Create the binding to the sforce servics
                sForce.SforceService binding = new sForce.SforceService();

                try {

                    // Time out after a minute
                    binding.Timeout = 60 * 1000;
                    loginResult = binding.login(un, pw);

                    // Check for a successful login
                    if (loginResult.sessionId.Trim().Length > 0) {
                        loggedIn = true;
                    }

Thanks,
Jason