调用激活“仅HTTPS”的Azure功能时出现TLS错误

问题描述 投票:0回答:1

我有一个ASP.NET应用程序,可以调用Azure函数。如果功能设置HTTP Only关闭,一切正常,但是当我打开它时,应用程序无法调用函数时出现以下错误:

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框架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;

azure-functions tls1.2
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.