无法建立 SSL 连接,请参阅内部异常。在 System.Net.HttpWebRequest.GetResponse()

The SSL connection could not be established, see inner exception. at System.Net.HttpWebRequest.GetResponse()

提问人:surji 提问时间:7/7/2023 更新时间:7/7/2023 访问量:64

问:

我正在使用 .net core v6 web api 并托管为 docker 容器,它在运行本地 iis 时工作正常,但是当我在 docker 中托管时出现错误,例如;

无法建立 SSL 连接,请参阅内部异常。在 System.Net.HttpWebRequest.GetResponse()

        StreamReader Reader;
        HttpWebRequest HttpRequest;
        HttpWebResponse HttpResponse;
        string ProviderResponse = "";
        try
        {

            HttpRequest = (HttpWebRequest)HttpWebRequest.Create(url + Request);
            HttpRequest.UserAgent = "useragent";
            HttpRequest.Method = WebRequestMethods.Http.Get;
            HttpRequest.Timeout = 60000;
            System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls ;
           
            HttpResponse = (HttpWebResponse)HttpRequest.GetResponse();
            Reader = new StreamReader(HttpResponse.GetResponseStream());
            ProviderResponse = Reader.ReadToEnd();
            Reader.Close();
            HttpResponse.Close();
        }
        catch (WebException ex)
        {
           string error = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
            
        }
docker ssl net-core asp.net-web-api httpwebrequest

评论


答: 暂无答案