Database Reference
In-Depth Information
Now that you have a certificate installed, you can search for and locate it with code. Usually, a
certificate is searched for by its unique identifier (
thumbprint
) or by its
common name
(CN). To view the
thumbprint of your certificate, double-click the certificate, select the Details tab, and scroll down until
you see the
Thumbprint
property, as shown in Figure 4-5.
Figure 4-5.
Obtaining a certificate's thumbprint
You can select the thumbprint and copy it into a string variable. The following code shows a new
private variable and a new method in the
Encryption
class you saw earlier. Line 1 contains the
thumbprint as seen in Figure 4-5, line 13 opens the root certificate store on
LocalMachine
, and line 17
instantiates an X.509 object by searching the thumbprint. Note that the
Find
method returns a
collection; you're interested in the first certificate because only one will match this thumbprint. On line