L
L
L1pton2018-10-31 17:21:18
Cryptography
L1pton, 2018-10-31 17:21:18

Collection of information about certificates?

Colleagues, good afternoon.
Please tell me, here's the question:
Is it possible within the same network to collect information (ideally, auto-export public keys to .cer) about certificates that are in personal storage? For example, uploading to CSV over the entire x.509 structure.
We want to inventory key data without waiting for feedback from our users.
User PCs, usually with Windows 7 Pro OS with CryptoPro 4.0 installed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Kuznetsov, 2018-10-31
@max-kuznetsov

Try this:
Getting a list of certificates:
X509Store store = new X509Store("My"); // private
store.Open(OpenFlags.ReadOnly); // read-only
foreach (X509Certificate2 mCert in store.Certificates){
// treat a specific certificate as an object X509Certificate2
}
Content to write to file:
StringBuilder builder = new StringBuilder();
builder.AppendLine("-----BEGIN CERTIFICATE-----");
builder.AppendLine(Convert.ToBase64String(cert.Export(X509ContentType.Cert), Base64FormattingOptions.InsertLineBreaks));
builder.AppendLine("-----END CERTIFICATE-----");
var s = builder.ToString();
Write to file:
File.WriteAllText("c:\\path\cert.cer", s);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question