mirror of
https://github.com/QL-Win/QuickLook.git
synced 2026-01-13 07:05:24 +08:00
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.
48 lines
1.3 KiB
C#
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()
|
|
{
|
|
}
|
|
}
|