There are various places in DicomObjects where it is necessary either to use or to receive and verify X509 certificates. Fortunately, there is already a well-established method of doing this within Windows using “CAPICOM” objects, which are supplied by Microsoft.
Full reference is available on the Microsoft web site
Recent systems and those which have had other software might already have CAPICOM installed,. but it might needed to be added. It is freely redistributable, and available from Microsoft, but only as part of a complete platform SDK, which is a little large just to get one component, so if necessary, it is also available from the Medical Connections web site.
The CAPICOM API provides multiple ways of storing and accessing certificates in this form, but simple visual basic code to retrieve the first user certificate with a suitable private key from the local certificate store might be:
Load Certificate |
Copy Code |
---|---|
Dim myStore As New Store Dim cert As Certificate myStore.Open CAPICOM_CURRENT_USER_STORE, CAPICOM_MY_STORE,CAPICOM_STORE_OPEN_READ_ONLY For Each cert In myStore.Certificates If cert.HasPrivateKey Then Exit For Next cert.Display |
This could then be used for any purpose where a certificate is needed in DicomObjects. e.g.:
MsgBox Viewer.ListenSecure(1000, cert, True)
Other methods are available, including importantly those for validation and extraction of data from certificates received from remote entities.