My salesforce res apis were working fine until. When suddenly I started getting authentication errors. retry your request.
Salesforce.Common.AuthenticationClient.d__1.MoveNext().
salesforce informed that it would use from now TLS .1.2. How can I enforce my asp.net core 2.0 to use TLS 1.2 in Startup.cs. below is my code for login.
private async Task<AuthenticationClient> GetValidateAuthentication()
{
RestApiSetting data = new RestApiSetting(Configuration);
var auth = new AuthenticationClient();
var url = data.IsSandBoxUser.Equals("true", StringComparison.CurrentCultureIgnoreCase)
? "https://test.salesforce.com/services/oauth2/token"
: "https://login.salesforce.com/services/oauth2/token";
try
{
//ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
await auth.UsernamePasswordAsync(data.ConsumerKey,
data.ConsumerSecret, data.Username, data.Password, url);
return auth;
}
catch (Exception ex)
{
throw new Exception(ex.ToString());
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…