OK, so this is going to be geeky and I wouldn’t normally post stuff like this to my Facebook page but for various reasons I can’t post to my blog right now and I want to capture this somewhere.
So in Windows there are several services related to the cryptography, certificates and smartcards; services are able to perform actions for the user and system in the background and enable application developers to do things in a least-privileged way.
One of the core services in these scenarios is the “Cryptographic Services” service; it does a bunch of things including the wire retrievals for CryptoAPI.
Specifically it is the worker for CryptRetrieveObjectByUrl which is used by Windows and other applications to gather evidence necessary to validate certificates, such evidence includes intermediate certificates, CRLs, OCSP responses and a file called commonly referred to as the Windows Certificate Trust List.
This API (at least in Windows 7) maintains a single cache for the whole system of the objects it has downloaded.
These files are kept in a hidden system folder called CryptNetUrlCache, in some cases you may want to test a scenario without relying on the cache, to do that you must flush the cache. The easiest way to do that is to open an administrative command prompt and run the following commands:
cd %WINDIR%\ServiceProfiles\LocalService\AppData\LocalLow\Microsoft\CryptNetUrlCache
attrib .\Content\*.* -s
del .\Content\*.*
attrib .\MetaData\*.* -s
del .\MetaData\*.*
%WINDIR%\SysWOW64\config\systemprofile\AppData\LocalLow\Microsoft\CryptnetUrlCache
attrib .\Content\*.* -s
del .\Content\*.*
attrib .\MetaData\*.* -s
del .\MetaData\*.*
%WINDIR%\System32\config\systemprofile\AppData\LocalLow\Microsoft\CryptnetUrlCache
attrib .\Content\*.* -s
del .\Content\*.*
attrib .\MetaData\*.* -s
del .\MetaData\*.*
%WINDIR%\ServiceProfiles\NetworkService\AppData\LocalLow\Microsoft\CryptnetUrlCache
attrib .\Content\*.* -s
del .\Content\*.*
attrib .\MetaData\*.* -s
del .\MetaData\*.*
Alternatively you can call this command:
certutil -URLcache * delete
No reboot is necessary, next time a component calls the CryptRetrieveObjectByUrl API it will not be able to satisfy that request with the cached data and will be forced to go on the wire.
One of the functions the service offers is the Automatic Update of the root store, a way to validate the cache is not being used is to:
- Remove all “Trusted Third Party CertificateAuthorities” from the Computer Account’s store using the Certificate Managementconsole.
- Clear the cache as described above
- Visit https://www.godaddy.com
- in IE
- Open Even Viewer\Application
- Sort on “Event ID”, find the 4097
Since every time a root is added a new event log entry is created you will see something that says “Successful auto update of third-party root certificate” in the event log, you will also see a few files in the above directories you previously cleared.
This all tells you that new wire retrieval took place and that the cache was not used.
You can of course also use tools like Reg/FileMon as well as Network Monitors to infer much of the same.
Hope this helps someone someday,
Ryan