Quantcast
Channel: Questions in topic: "webrequest"
Viewing all articles
Browse latest Browse all 387

Error getting response stream (Write: The authentication or decryption has failed.): SendFailure

$
0
0
Hello! I have a script that call a webservice over https build with swagger in C# and I´m getting: Error calling AuthenticatePost: Error getting response stream (Write: The authentication or decryption has failed.): SendFailure I already imported all the certifies from the moztools.exe and even used certmgr.exe to add the url from where I call the webservice, but it didnt worked. Now I´m using the ServicePointManager.ServerCertificateValidationCallback but it never enters my callback, here is my code: public Object CallApi(String path, RestSharp.Method method, Dictionary queryParams, String postBody, Dictionary headerParams, Dictionary formParams, Dictionary fileParams, String[] authSettings) { var request = new RestRequest(path, method); //UpdateParamsForAuth(queryParams, headerParams, authSettings); // add default header, if any foreach(var defaultHeader in _defaultHeaderMap) request.AddHeader(defaultHeader.Key, defaultHeader.Value); // add header parameter, if any foreach(var param in headerParams) request.AddHeader(param.Key, param.Value); // add query parameter, if any foreach(var param in queryParams) request.AddParameter(param.Key, param.Value, ParameterType.GetOrPost); // add form parameter, if any foreach(var param in formParams) request.AddParameter(param.Key, param.Value, ParameterType.GetOrPost); // add file parameter, if any foreach(var param in fileParams) request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType); if (postBody != null) // http body (model) parameter request.AddParameter("application/json", postBody, ParameterType.RequestBody); ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => { return true; }); return (Object)RestClient.Execute(request); } public static bool RemoteCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { UnityEngine.Debug.Log("MyRemoteCertificateValidationCallback"); bool isOk = true; // If there are errors in the certificate chain, look at each error to determine the cause. if (sslPolicyErrors != SslPolicyErrors.None) { for (int i = 0; i < chain.ChainStatus.Length; i++) { if (chain.ChainStatus[i].Status != X509ChainStatusFlags.RevocationStatusUnknown) { chain.ChainPolicy.RevocationFlag = X509RevocationFlag.EntireChain; chain.ChainPolicy.RevocationMode = X509RevocationMode.Online; chain.ChainPolicy.UrlRetrievalTimeout = new TimeSpan(0, 1, 0); chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllFlags; bool chainIsValid = chain.Build((X509Certificate2)certificate); if (!chainIsValid) { isOk = false; } } } } return isOk; } Why eventhoug I added the certificates it doesnt work, and why is the delegate callback not being called? Thanks in advance.

Viewing all articles
Browse latest Browse all 387

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>