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
aravind swaminathanaravind swaminathan 

Tried upgrading to TSL1.2 from TSL1.0 for Salesforce API and getting Invalid username, password, security token


We tried to upgrade to TSL1.2 using
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
conn = new SalesforceConnection(userNAME, passWORD, secTOKEN);

in our .NET Console Application to connect to Salesforce and we are getting the error below when  initializing the connection.

INVALID_LOGIN: Invalid username, password, security token; or user locked out.

Can you please let me know what am i doing wrong here and please suggest a fix for this?

Thanks in Advance.
Ajay Anikar H RAjay Anikar H R
Hi Aravind,

i would run couple of verification for these error messages:

1. Are you connecting to the correct environment? Production ( v/s Sandboxes (
2. Have you verified with the login history if the connection is indeed hitting the right environment ?

Should give you some hints as where its going wrong...
Gerald WangGerald Wang
Hi Aravind

Does it work now? Can you please let me know how to set up:

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

Many thanks.
aravind swaminathanaravind swaminathan

Thanks its working now.I was pointing to diiferent environment.
aravind swaminathanaravind swaminathan
Hi Wang,

Just use ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; before your connection and it should work fine.
Gerald WangGerald Wang
Thanks for your help, do you have any other options?