Search code examples
validationcertificatesql-server-ce

Certificate validation using internet to validate unnecessarily?


I have an application that receives items from a high-speed scanner device. As the items are received, they are written to disk using SQL Compact. The following digitally signed Microsoft DLLs are used:

    sqlceca40.dll
    sqlcecompact40.dll
    sqlceer40EN.dll
    sqlceme40.dll
    sqlceoledb40.dll
    sqlceqp40.dll
    sqlcese40.dll

I recieved a performance complain from a customer, and traced the issue using Microsoft Procmon to a TCP Reconnect failure when attempting to contact the site for certificate validation when we make calls to methods in these dlls. At first, I could not recreate the issue locally. After talking to their infrastructure people and developers, I learned that they must use a proxy for internet connectivity. Some of the customer's users (in the test environment) had valid proxy settings, and they got good performance from our application. Naturally when they turned their proxy settings off, the validation could not be done and the performance issue arose.

I attempted to recreate the issue by setting our machine up with false proxy settings to a non-existent machine. On my initial attempt, I still got good performacne from our application, and no attempt was made to contact the internet for cert validation. After looking at the cert's validation chain, I noticed that it derived from the certificate "Microsoft Root Certificate Authority". I then exported and deleted that Cert, and was able to reproduce the issue as determined by a comparison of logs.

I did the following tests:

    Test 1:
    1. Opened the proxy settings, and enabled them pointing to a non-existent address.
    2. Ran a test.   
    Results: No performance issue.

    Test 2:
    1. Exported the “Microsoft Root Certificate Authority” cert and moved it to the untrusted folder.
    2. Ran a test.  
    Results: The performance issue occurred.

    Test 3:
    1. Deleted the “Microsoft Root Certificate Authority” cert.
    2. Started a test.  
    Results: The performance issue began occuring.
    3. While the test was in progress and device was hesitating I removed the false proxy settings.  
    Results: The performance issue disappeared and the application recovered.

    Tentative Conclusions:
    1. That I can simulate the no internet access condition by providing false proxy settings.
    2. If the “Microsoft Root Certificate Authority” cert is installed properly, the .Net infrastructure does not need to access the network to verify the necessary cert.
    3. If not, it will attempt to validate via the internet connection.

Nevertheless, when the customer checked the certificates in the "Trusted Roots Certificates" folder of mmc->certificates-local computer. The "Microsoft Root Certificate Authority" certificate does appear there, and it seems to be identical to mine. Yet for some reason the use of the dll's causes certificate validation to attempt to access the internet resulting in a performance issue.

In the customer's situation, eventually devices will be used in production with no internet access.

My question is, is there a setting (registry, or GPO) that might cause certificate validation to always attempt to use the internet, regardless of whether the root certificate of the validation chain is installed in the local computer?

Can a setting be enabled that causes a certificate validation to access the internet to check to see if the root certificate has been revoked, for example?

Please feel free to ask questions if you need more information.


Solution

  • This appears to occur for SQL Server Compact 4.0 on any system with an invalid proxy configuration, as a Certificate Revocation List check is run each time the engine is loaded (which happens on the first call to .Open()).

    Solution: To avoid this delay, which probably affects any signed app on the system in question, you must fix the configuration or disable the check. The check can be disabled via UI or via registry settings, as described here: http://digital.ni.com/public.nsf/allkb/18E25101F0839C6286256F960061B282

    For additionla issues see my blog post here: http://erikej.blogspot.com/2013/08/faq-why-is-opening-my-sql-server.html