开发者

How can I display a dialog box that contains the properties of an X.509 certificate?

I want to display dialog box that contains properties of an X509 Cert. That box includes three tabs:

  1. General
  2. Details
  3. Certification path

As in this image.

How can I display a dialog box that contains the properties of an X.509 certificate?

With C# i use a statement:

X509Certificate2UI.DisplayCertificate(X509Certificate2 cert);
开发者_如何学Go

But with Java, I can't find similar statement!

How can I display a dialog box that contains the properties of an X.509 certificate?


As far as I could track, the .NET will use following function to display the cert information:

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
internal class CRYPTUI_VIEWCERTIFICATE_STRUCTW
{
    internal uint dwSize;
    internal IntPtr hwndParent;
    internal uint dwFlags;
    internal string szTitle;
    internal IntPtr pCertContext;
    internal IntPtr rgszPurposes;
    internal uint cPurposes;
    internal IntPtr pCryptProviderData;
    internal bool fpCryptProviderDataTrustedUsage;
    internal uint idxSigner;
    internal uint idxCert;
    internal bool fCounterSigner;
    internal uint idxCounterSigner;
    internal uint cStores;
    internal IntPtr rghStores;
    internal uint cPropSheetPages;
    internal IntPtr rgPropSheetPages;
    internal uint nStartPage;
    public CRYPTUI_VIEWCERTIFICATE_STRUCTW();
}

[DllImport("cryptui.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern bool CryptUIDlgViewCertificateW(
    [In, MarshalAs(UnmanagedType.LPStruct)] CRYPTUI_VIEWCERTIFICATE_STRUCTW ViewInfo, 
    [In, Out] IntPtr pfPropertiesChanged);

I am not a java expert, and unsure how is it possible to call Windows functions from java, but there must be a way. Look at MSDN for CryptUIDlgViewCertificate function, and you will know the details

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜