在激活“仅HTTPS”的情况下调用Azure函数时的TLS错误

时间:2018-12-06 12:39:47

标签: azure-functions tls1.2

我有一个ASP.NET应用程序,可以调用Azure函数。如果仅关闭“功能”设置“ HTTP仅”,则一切正常,尽管当我打开它时,应用程序无法使用以下错误调用“功能”:

Exception:
System.AggregateException: One or more errors occurred.
---> System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send.
---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

功能配置为:

enter image description here

该应用程序在.net Framework 4.6.1上运行。遵循调用函数的代码:

client = new HttpClient
{
    BaseAddress = new Uri("https://myfunction.azurewebsites.net/")
};

client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

var request = new Email(to, from, subject, body);

var response = client.PostAsync("/api/SendEmail", request, ClientUtil.GetJsonMediaType()).Result;

我不想设置ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls12;

1 个答案:

答案 0 :(得分:0)

我已经放弃,只是使用tls12指令强制执行了代码。 :(