Created
November 4, 2014 14:35
-
-
Save jonman364/88f1fe45780c77045a89 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.IO; | |
using System.Security.Cryptography.X509Certificates; | |
namespace certreg { | |
class Program { | |
static void Main(string[] args) { | |
if(args.Length == 0) { | |
Console.WriteLine("Useage:\n\tcertreg path"); | |
return; | |
} | |
if(!Directory.Exists(args[0])) { | |
Console.WriteLine("Cannot open \"" + args[0] + "\""); | |
return; | |
} | |
X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine); | |
store.Open(OpenFlags.ReadWrite); | |
foreach(string filePath in Directory.EnumerateFiles(args[0], "*.pfx")) { | |
string password = Path.GetFileNameWithoutExtension(filePath); // Where cert password = filename | |
X509Certificate2 cert = new X509Certificate2(filePath, password); | |
store.Add(cert); | |
Console.WriteLine(password); | |
} | |
store.Close(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment