Social Network

Twitter

Tag: cryptography

April 2, 2015 by wholroyd·Comments Off on Agent-less method to enumerate certificates on a remote machine

Ever needed to enumerate certificates installed on a remote machine using just C# and .NET without having to use an agent? It was a problem I’ve had a couple of times now and was able to figure out without the help of MSDN or StackOverflow. I discovered the X509Store class has the power to solve this problem for us as it utilizes the C++ CertOpenStore functionality underneath, but it’s not documented anywhere. As a result, you can use some of the same functionality as the underlying library at the C# level, just by simply doing this…

[gist https://gist.github.com/wholroyd/b7026197c485c6085c60]

It’s evidently the second time I’ve had to do this type of lookup. Luckily I remembered to post the answer back to my own StackOverflow question years ago.

Share

I was asked by another developer recently that was struggling to find a way to provide a Guid that was somehow a hashed value of a given string. The idea was that for any provided string, it would always return the same Guid value. They weren’t concerned with duplicates as that was taken care of using some other set of business logic.

The best thing that came to mind that accomplished this was pushing the string through the MD5 crypto provider and then feeding it into the Guid constructor. The output from the provider is 16 bytes, which just so happens to be the matching array size that the Guid constructor hopes to receive.

Weirdly, neither him or any of the other developers on his team knew about this trick. So I figure it’s something that should be worth posting as it didn’t seem obvious to them, and I guess I should make use of this blog thing every once in a while given that I pay $10/month for it.