Exemple #1
0
        void buttonSelectEndpointCert_Click(object sender, EventArgs e)
        {
            try
            {
                SafeCertificateStore storeHandle = CertificateManager.GetCertificateStorePointer(machineName);

                // do not display the Location column on the CryptUIDlgSelectCertificateFromStore
#pragma warning suppress 56523
                SafeCertificateContext certContext = SafeNativeMethods.CryptUIDlgSelectCertificateFromStore(
                    storeHandle,
                    propPage,
                    SR.GetString(SR.SSLBindingTitle),
                    SR.GetString(SR.SSLBindingMessage),
                    SafeNativeMethods.CRYPTUI_SELECT_LOCATION_COLUMN,
                    0, IntPtr.Zero);

                if (!certContext.IsInvalid)
                {
                    config.X509Certificate   = certContext.GetNewX509Certificate();
                    textBoxEndpointCert.Text = GetDisplayStringForCert(config.X509Certificate);
                    ComponentChanged();
                }

                certContext.Close();
                storeHandle.Close();
            }
            catch (WsatAdminException ex)
            {
                HandleException(ex);
            }
        }