I have just installed monodevelop from ubuntu software centre and created a solution. I am trying to do WebRequest.create(url). But it keeps throwing “The authentication or decryption has failed”. What am I doing wrong? If I am not doing anything wrong what should I do to make the above work!
I have searched about this but I couldn’t come up with a solution that will fix my problem!
Here is what I do …
public static string AccessURL(string url, string postcontent)
{
WebRequest request = WebRequest.Create(url);
request.Method = "POST";
byte[] byteArray = Encoding.UTF8.GetBytes(postcontent);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse response = request.GetResponse();
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
reader.Close();
dataStream.Close();
response.Close();
return responseFromServer;
}
Thanks in advance!
The error suggests that you are trying to access a SSL/TLS encrypted resource. Mono does not trust any these sites per default and is up to the developer to determine whether you want to access that resource or not. More about this in mono’s security FAQ.
So one way to do this is to implement a ServerCertificateValidationCallback in your class:
There are more examples in the mono documentation about using Certificate Policies and Trusting Roots. Notice the sample above ignores the security and accepts all certificates, even those you might not trust. This is not recommended to use!