Thursday, February 7, 2019

List of RSA Key Container Names


List RSA key container

If you are struggling to get which RSA key installed on your machine then this post will help you in this. There is no straight forward thing that will give you the installed RSA containers names. With the help of below steps you will be able to get the list of installed RSA key container names.

So, without wasting any time more let’s jump on the solution.

Step 1. Open visual studio IDE and create a console application

Step 2. Add “using System.IO;” namespace to the program class

Step 3. Add below code in Main method
var files = System.IO.Directory.GetFiles(@"C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\");

            foreach (var f in files)
            {
                // try catch is to avoid some ACL issues on certain files
                try
                {
                    byte[] bytes = File.ReadAllBytes(f);
                    string containerName = Encoding.ASCII.GetString(bytes, 40, bytes[8] - 1);

                    Console.WriteLine(containerName);
                }
                catch (Exception)
                {

                }


No comments: