I have a web service to retrieve Certificate info from LocalMachine's Trusted Root Certification. It works on Win 2008 R2 web server, but crashes on Win 2012 Server R2.
Here is the code:
Imports Microsoft.Web.Services2.Security.X509
Imports Microsoft.Web.Services2.Security.Tokens
Dim store As X509CertificateStore = Nothing
Dim col As X509CertificateCollection
store = X509CertificateStore.LocalMachineStore(X509CertificateStore.TrustStore)
store.OpenRead()
col = CType(store.FindCertificateBySubjectString("My Certificate Serial"), X509CertificateCollection)
store.Close()
The web service crashed at the last line - calling FindCertificateBySubjectString()
The err msg is "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
The same func code can work correctly when executing it within a Windows standalone app.
Please help!
Thank you in advance
Mark