0

我正在尝试将linkedin API v2集成到dnn(客户模块)但是当尝试通过httpclient request获取令牌时。它产生错误请求被中止:无法创建 SSL/TLS 安全通道。

它适用于 mvc c# .net 应用程序,但在 dnn 模块上它失败并出现上述错误。您在这方面的友好帮助将不胜感激

它适用于 mvc c# .net 应用程序,但在 dnn 模块上它失败并出现上述错误。您在这方面的帮助将不胜感激。我已经尝试了 stackoverflow 上提到的几乎所有解决方案,但都失败了。

将 Dnn V9.3 与 Framework 4.5(4.6 也尝试过)DAL2 模块模板一起使用。本地主机与http://localhost

 public async void SaveLinkedinTok(string code, string state, string error, string error_description)
        {
            if(string.IsNullOrEmpty(code))
            {
                return View("Error");
            }

            var httpClient = new HttpClient
            {
                BaseAddress = new Uri("https://www.linkedin.com/")
            };
            var requestUrl = $"oauth/v2/accessToken?grant_type=authorization_code&code={code}&redirect_uri={AppConfig.Get("Linkedin.RedirectUrl")}&client_id={AppConfig.Get("Linkedin.ClientID")}&client_secret={AppConfig.Get("Linkedin.SecretKey")}";
            var response = await httpClient.GetAsync(requestUrl);
            var token = JsonConvert.DeserializeObject<TokenResponse>(await response.Content.ReadAsStringAsync());

System.Net.Http.HttpRequestException:'发送请求时发生错误内部异常 WebException:请求被中止:无法创建 SSL/TLS 安全通道。

4

1 回答 1

1

尝试以下操作:

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

var httpClient = new HttpClient
{
    BaseAddress = new Uri("https://www.linkedin.com/")
};

...
于 2019-05-16T00:27:42.123 回答