CSelectCertificateDlg

A certificate selection dialog class
Download

CSelectCertificateDlg Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Freeware
  • Publisher Name:
  • Naughter Software
  • Operating Systems:
  • Windows All
  • File Size:
  • 0 KB

CSelectCertificateDlg Tags


CSelectCertificateDlg Description

The CSelectCertificateDlg was developed to be a certificate selection dialog class. The application is compiled with manifest support in VC 200. It shows digital certificates if running on a computer which has had a number of certificates installed by the product "WMWare Server" Main features: Simple CDialog based class which integrates with MFC and which implements the certificate selection functionality. All the code is fully UNICODE compliant. Will work on Windows 98 or NT 4 SP4 or later. The dialog is wider than the built in dialogs meaning that there is less issues with column names being clipped. All localizable content for the dialog is taken from the resources, meaning that the class is easily localizable. The caption and prompt text can be customized ("CSelectCertificateDlg::m_sTitle" & "CSelectCertificateDlg::m_sDisplayString"). If no values are provided for these, then the standard values as shown in the screen capture above (and the same as the built in dialogs) will be used. The details of the certificate can be examined via the "View Certificate" button which uses the Windows Cryptography function "CryptUIDlgViewCertificate" which is only available on 2000 or later. The code uses GetProcAddress to handle the lack of this function on down level operating systems. In addition you can programmatically exclude the button by using "CSelectCertificateDlg::m_bHideViewCertificateButton". When the "View Certificate" button is not being shown, the code automatically moves over the "OK" and "Cancel" buttons to the right to preserve the standard UI look. The presence or absence of each column can be customized through "CSelectCertificateDlg::m_bExclude*Column". Please note that unlike the built in dialogs, CSelectCertificateDlg does not show the "Location" column as I was unable to find any documentation on what exactly this column showed. In all the tests I did it always displayed "Not Available". If you know what should go in here, then please drop me a note and I can easily add it in for the next release. The code tries to match the UI of the built in dialogs as much as possible, for example the list control uses an image list and the general location of all the UI elements is much the same. Which certificate store's certificates are shown is determined by "CSelectCertificateDlg::m_hCertStore". The dialog can operate in a multi select or single select mode. High level helper functions are provided (CSelectCertificateDlg::GetCertificatesShownCount, CSelectCertificateDlg::GetCertificateShown and CSelectCertificateDlg::GetNextSelectedCerfificateShown) to get the dialog state after it has been shown. The class performs automatic clean up of all certificate resources it uses. You should read the various notes in "SelectCertificateDlg.h" on who is responsible for the lifetime management of the various resources which the class provides access to through the functions discussed in the previous point. Label Tips are enabled on the list control (unlike the built in dialogs!) meaning that column text which overflows the column boundaries are shown as tooltips. This is especially important for the "Intended Purposes" column which can contain 30+ enhanced key usage strings. In addition the code to display the enhanced key usage strings should provide a good tutorial on how you can obtain these various properties from a certificate using the CryptoAPI. Provides a production quality sample on how to use the various Crypto Certificate and Certificate Store APIs. This area seems to be sorely lacking good examples for the novice developer who has to deal with the complicated area of the Windows Cryptography API. As mentioned in the intro above. CSelectCertificateDlg provides a key feature which is missing from the built in dialogs, namely customization of the initial selection state. If you would like to select a specific single certificate then you can use CSelectCertificateDlg::SetInitialSelectedCert. If you do not provide a certificate, then by default the first certificate enumerated will be shown selected (which is the same behaviour as the built in dialogs). If neither of these modes or operation are appropriate, then almost all of the class's functionality can be customized through the use of virtual functions. For further info, please take a look at the functions AddCertificate, AddCertificateToUI and EnumerateCertificates functions. Finally since the code is open source, all the code is provided, so even if you are happy using one of the built in Certificate selection API calls instead of using CSelectCertificateDlg, you can see through example how each of them would implement their functionality (of course the MS implementation would probably be developed directly to the Windows API instead of using the MFC framework!).


CSelectCertificateDlg Related Software