This is really strange, and I canβt understand why one method works and the other does not.
I have a certificate in my local computer store and a fingerprint for it. The application uses the certificate when making HTTP requests, so I need to get it. I want to save the fingerprint in the web.config file as the value of AppSetting. Whenever I pull out the AppSetting value and use it to search for a certificate, it does not find it. However, if I create a local variable (class variable, readonly, const, whatever ...) and search on it, it works. I did String.Compare () and the value is equally accurate . What gives? I tried to look at IL to see if I could see something scared, but nothing.
' This Works '
Dim certificateThumbprint As String = "D0650C9D31CF525D3C82153DCEBC3C3265D75FE3"
Dim certCollection = certStore.Certificates.Find(X509FindType.FindByThumbprint, certificateThumbprint, False)
' This doesn't '
Dim appSettingcertificateThumbprint = System.Web.Configuration.WebConfigurationManager.AppSettings("CertificateThumbprint")
Dim certCollection2 = certStore.Certificates.Find(X509FindType.FindByThumbprint, appSettingcertificateThumbprint, False)
' Intermediate window shows that '
String.Compare(certificateThumbprint, appSettingcertificateThumbprint, True) = 0
source
share