issue in sending Async notification to one server

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.

  • 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

  • Not getting any security warning in problem list as of now. We are able to send the notification to other similar servers.

  • In that case I would suggest to use Visual Studio and debug the code. For more details see admhelp.microfocus.com/.../t_scripted_rule_debug.htm

  • Still Issue is not yet resolved. TSL/SSL issue we are getting.

  • 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);

  • Please try to always return true from your ServerCertificateCustomValidationCallback