相关疑难解决方法(0)

使用HttpWebRequest/HttpWebResponse获取HTTP请求和响应以在Fiddler中显示

有什么方法可以将Fiddler捕获到使用.NET HttpWebRequest和HttpWebResponse捕获请求和响应吗?

.net httpwebrequest fiddler httpwebresponse

39
推荐指数
2
解决办法
3万
查看次数

RestSharp 请求中止 - 无法创建 SSL/TLS 安全通道

我正在尝试使用 RestSharp 在我的本地机器上测试 API 调用,并使用以下代码...

        var client = new RestClient("https://[API URL]");

        var request = new RestRequest( Method.POST);
        request.AddParameter("session", this, ParameterType.RequestBody);

        IRestResponse<SessionOut> response = client.Execute<SessionOut>(request);
        return response.Data.session.id;
Run Code Online (Sandbox Code Playgroud)

response我收到一条错误消息,告诉我请求已中止,因为它“无法创建 SSL/TLS 安全通道”。

这是否意味着我需要尝试设置https://localhost而不是http://localhost才能在 https:// 地址调用 API?

更新

根据下面@Shai_Aharoni 的回答,我已将我的代码更新为以下内容。但是,我仍然遇到相同的错误。

        string pathToYourClientCert = Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "[my certificate file");
        var client = new RestClient("[API URL]/");
        client.ClientCertificates = new X509CertificateCollection();
        client.ClientCertificates.Add(new X509Certificate(pathToYourClientCert));

        var request = new RestRequest( Method.POST);
        request.AddParameter("session", this, ParameterType.RequestBody);

        IRestResponse<SessionOut> response2 = client.Execute<SessionOut>(request);
Run Code Online (Sandbox Code Playgroud)

c# asp.net ssl restsharp

2
推荐指数
1
解决办法
6697
查看次数

标签 统计

.net ×1

asp.net ×1

c# ×1

fiddler ×1

httpwebrequest ×1

httpwebresponse ×1

restsharp ×1

ssl ×1