X509Certificate2.Archived Property
Gets a value that indicates whether the certificate is archived.
Property Value
System.Boolean
true if the certificate is archived; otherwise,
false.
Remarks
The Archived property returns true if the
certificate has been archived. This property is typically used to
manage certificates in a certificate store. An archived certificate
can be identified and then retrieved and stored offline.
When a certificate is exported, it can be marked as archived. This indicates that the certificate is no longer in active use but should be retained for historical or auditing purposes.
If a certificate has not been explicitly marked as archived, this
property will return false.
Example
using System;
using System.Security.Cryptography.X509Certificates;
public class Example
{
public static void Main(string[] args)
{
// Load a certificate from the CurrentUser Personal store
X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
try
{
// Assume we have a certificate with a specific thumbprint
// Replace with a valid thumbprint from your store
string thumbprintToFind = "YOUR_CERTIFICATE_THUMBPRINT";
X509Certificate2Collection certificates = store.Certificates.Find(X509FindType.FindByThumbprint, thumbprintToFind, false);
if (certificates.Count > 0)
{
X509Certificate2 cert = certificates[0];
Console.WriteLine($"Certificate: {cert.SubjectName.Name}");
Console.WriteLine($"Archived: {cert.Archived}");
if (cert.Archived)
{
Console.WriteLine("This certificate is marked as archived.");
}
else
{
Console.WriteLine("This certificate is not archived.");
}
}
else
{
Console.WriteLine($"Certificate with thumbprint '{thumbprintToFind}' not found.");
}
}
finally
{
store.Close();
}
}
}
Requirements
| Assembly | File name |
|---|---|
| System.Security.Cryptography.X509Certificates | System.Security.Cryptography.X509Certificates.dll |
See Also
X509Certificate2 Class
System.Net.Security Namespace
The Archived property is read-only and its value
is determined when the certificate is loaded or imported.