We are trying to send notification to one server using c# scripts. In local this is working fine and giving response. But after deploying to server it is not working. Not even sending the notification. Firewall is working fine.
Cybersecurity
DevOps Cloud (ADM)
IT Operations Cloud
If an answer to your question is correct, click on "Verify Answer" under the "More" button. The answer will now appear with a checkmark. Please be sure to always mark answers that resolve your issue as verified. Your fellow Community members will appreciate it!  Learn more
SV Server has C# sandbox enabled by default, which doesn't allow network calls, disk access and so on. If this is the case, you would see Security related warnings in the Problems List and in the log file. Is this the case? If so, you can either disable sandbox or add security exceptions. Please see this help page to get the details: admhelp.microfocus.com/.../t_scripted_rule_Csharp.htm
Why you didn't said so right away? If it is SSL issue and it is working on one machine, but not on the other, the problem is likely in the trust store.
If you are using built-in .NET classes, then they are using Windows Credential Store. Please examine the exception/certificate of the remote endpoint and add the certificate(s) to your respective trust store. Alternatively, you can ignore SSL validation errors. More info about that for example here - stackoverflow.com/.../c-sharp-ignore-certificate-errors
If you still have problems, please copy-paste relevant snippet of your log file and your code.
Hi Jacob,
I tried the code snippet from stackoverflow. But facing new issue. Could you please help me. If I add the certificate in SV server. will it work? Will it affect any other services?
Scripted Rule: System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at HP.SV.CSharpRule.<Execute>d__0.MoveNext() in C:\ProgramData\Micro Focus\Service Virtualization Server\Scripts\Rules\0689f1d4-2fba-4105-9e44-e62364742141\SvMain.cs:line 94
---> (Inner Exception #0) System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
--- End of inner exception stack trace ---<---
Code -
int milliseconds = 1000;
await Task.Delay(milliseconds);
try{
using (var httpClientHandler = new HttpClientHandler())
{
httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, sslPolicyErrors) => {
if (sslPolicyErrors == SslPolicyErrors.None)
{
return true; //Is valid
}
if (cert.GetCertHashString() == "55d668c3ab5dc01d797dfdbea5fde615de63ead2")
{
return true;
}
return false;
};
using (var httpClient = new HttpClient(httpClientHandler))
{
var httpResponse = httpClient.GetAsync("">ordermanager.hansen-com-test.aws.dishcloud.io").Result;
}
} Stream dataStream = http.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
// Get the response.
WebResponse response = http.GetResponse();
// Display the status.
Console.WriteLine(((HttpWebResponse)response).StatusDescription);