I have the following code (Core 3.1 in VS2019):
var client = new RestClient(url);
ServicePointManager.Expect100Continue = true;
ServicePointManager.DefaultConnectionLimit = 9999;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
// Add certificate
var certFile = Path.Combine(certificateFolder, certificateFile);
X509Certificate2 certificate = new X509Certificate2(certFile, certificatePassword);
client.ClientCertificates = new X509CertificateCollection() { certificate };
// Set web proxy
// client.Proxy = new WebProxy(proxyUrl, proxyPort) { BypassProxyOnLocal = false };
client.Proxy = new WebProxy("127.0.0.1", 8888);
// Create request; add headers and parameters
var request = new RestRequest(Method.POST);
request.AddParameter("Authorization", authorization, ParameterType.HttpHeader);
request.AddParameter("Content-Type", "application/x-www-form-urlencoded", ParameterType.HttpHeader);
request.AddParameter("grant_type", "client_cert");
request.AddParameter("scope", "openid");
IRestResponse response = client.Execute(request);
if (!response.IsSuccessful || response.StatusCode != HttpStatusCode.OK || response.ErrorException != null)
{
throw new Exception("Unexpected response.");
}
System.Diagnostics.Debug.WriteLine(response);
I have the proxy set to local host so that I can capture what is happening in Fiddler.
In Fiddler it is showing the following error:
fiddler.network.https> HTTPS handshake to myApiEndpointUrl (for #25) failed. System.Security.Authentication.AuthenticationException A call to SSPI failed, see inner exception. < The message received was unexpected or badly formatted
Win32 (SChannel) Native Error Code: 0x80090326
When I look at the Headers tab (in Fiddler) all it shows is:
Response Headers
HTTP/1.1 200 Connection established
The other tabs show similar or nothing.
Questions: 1. How can I view what is actually being sent, in other words, are the headers and parameters not being attached correctly? 2. Even when I look at the value of request in debug mode at the time of execution it doesn't provide me with a way of seeing the headers/parameters.
Thanks,
User contributions licensed under CC BY-SA 3.0