public static void ShowCertificate(X509Certificate2 certificate, IWin32Window parent = null) { var structConfiguration = new CRYPTUI_VIEWCERTIFICATE_STRUCT(); structConfiguration.dwSize = (uint)Marshal.SizeOf(typeof(CRYPTUI_VIEWCERTIFICATE_STRUCT)); structConfiguration.pCertContext = certificate.Handle; structConfiguration.szTitle = "Fiddler: Certificate Information"; structConfiguration.dwFlags = ViewCertificateFlags.CRYPTUI_DISABLE_EDITPROPERTIES; structConfiguration.nStartPage = 0; structConfiguration.hwndParent = parent?.Handle ?? IntPtr.Zero; var propertiesChanged = false; if (!Cryptui.CryptUIDlgViewCertificate(ref structConfiguration, ref propertiesChanged) && Marshal.GetLastWin32Error() != WinErr.ERROR_CANCELLED) { MessageBox.Show("An error occurred viewing the certificate."); } }
public static extern bool CryptUIDlgViewCertificate(ref CRYPTUI_VIEWCERTIFICATE_STRUCT pCertViewInfo, ref bool pfPropertiesChanged);