Hi,
I am trying to send a file to third party URL through 'System.Net.HttpWebRequest' in Ax 2012.
When system reaches the place 'response = request.GetResponse();', I am getting the error 'The remote certificate is invalid according to the validation procedure.'.
I have installed respective third party certificate still i am getting the above error.
Below is my job,
CLRObject clrObj;
str destinationUrl;
System.Net.HttpWebRequest request;
System.Net.HttpWebResponse response;
System.IO.Stream requestStream, responseStream;
System.IO.StreamReader streamReader;
System.Exception exception;
try
{
new InteropPermission(InteropKind::ClrInterop).assert();
clrObj = System.Net.WebRequest::Create(destinationUrl);
request = clrObj;
request.set_Method("GET");
response = request.GetResponse();
responseStream = response.GetResponseStream();
streamReader = new System.IO.StreamReader(responseStream);
responseXml = streamReader.ReadToEnd();
info(responseXml);
}
catch (Exception::CLRError)
{
exception = CLRInterop::getLastException().GetBaseException();
error(exception.get_Message());
}
In order to bypass this error i am trying to write the below code.
System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Security.Cryptography.X509Certificates.X509Chain chain,
System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true; // **** Always accept
};
Issue: I am not able to get the property of 'ServerCertificateValidationCallback ' from the class 'System.Net.ServicePointManager' as its throwing syntax error.
Anybody faced this issue before? Kindly help me to fix either of the issue.
Note: I am able to access the URL through Internet explorer by clicking 'continue to this website' option.
Ax versions: AX 2012 R3,
.Net framework version: 4.5.1