Files
QuickLook/QuickLook.Plugin/QuickLook.Plugin.CertViewer/CertViewerControl.xaml.cs
ema dba41ac890 Add certificate viewer plugin
Introduces QuickLook.Plugin.CertViewer for viewing certificate files (.pfx, .cer, .pem, etc.) in QuickLook. The plugin loads and displays certificate details or raw content, and is integrated into the solution and project files.
2025-12-23 14:15:52 +08:00

48 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
using System.Windows.Controls;
namespace QuickLook.Plugin.CertViewer;
public partial class CertViewerControl : UserControl, IDisposable
{
public CertViewerControl()
{
InitializeComponent();
}
public void LoadCertificate(X509Certificate2 cert)
{
var items = new List<KeyValuePair<string, string>>
{
new("Subject", cert.Subject),
new("Issuer", cert.Issuer),
new("Thumbprint", cert.Thumbprint),
new("SerialNumber", cert.SerialNumber),
new("NotBefore", cert.NotBefore.ToString()),
new("NotAfter", cert.NotAfter.ToString()),
new("SignatureAlgorithm", cert.SignatureAlgorithm.FriendlyName ?? cert.SignatureAlgorithm.Value),
new("PublicKey", cert.PublicKey.Oid.FriendlyName ?? cert.PublicKey.Oid.Value),
};
PropertyList.ItemsSource = items;
RawText.Text = string.Empty;
}
public void LoadRaw(string path, string message, string content)
{
PropertyList.ItemsSource = new List<KeyValuePair<string, string>>
{
new("Path", path),
new("Info", message)
};
RawText.Text = content ?? "(No content to display)";
}
public void Dispose()
{
}
}