Can turning on certification validation result in Application Insights data loss?

108 views Asked by At

We are using Microsoft Application Insights for logging telemetry data. Suddenly it has stopped logging data for most of the users. We do the logging from a WPF application. We are suspecting turning on a ServicePointManager.ServerCertificateValidationCallback has contributed to the problem. Here is the code of the callback -

     public static bool CertificateValidationCallBack(
     object sender,
     X509Certificate certificate,
     X509Chain chain,
     System.Net.Security.SslPolicyErrors sslPolicyErrors)
     {
        bool isCertificateValid = true;

        try
        {
            var certificate2 = new X509Certificate2(certificate);
            isCertificateValid = certificate2.Verify();
        }
        catch
        {
        }

        return isCertificateValid;
     }

Depending on a config value we are attaching the call back else we are setting it to null. Here is how we are ServicePointManager.ServerCertificateValidationCallback value -

if (!AllowFiddler)
{
     ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;
}
else
{
     ServicePointManager.ServerCertificateValidationCallback = null;
}

The above block is executed each time we send out an async request using HttpClient.

Is there anything wrong with the code? Does Application Insights SDK keep any log that can be used to investigate the data loss? I have looked into %localappdata%/Microsoft/ApplicationInsights folder - it contains only empty folders. Any idea on how can I troubleshoot this issue?

0

There are 0 answers