I work on an IIS6/ASP.NET website that must "require client certificates" in the form of a smart card (specifically a Common Access Card). I need to create a few services to access various URLs on a timer to do things like update search indices, warm up Sharepoint pages, and other tasks.
How can this be done, given that the site doesn't allow access unless you have a certificate, which is on the smartcard? I have tried to load the certificate (.cer) and load it in like this:
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create("https://.../someURL.html");
const string certFilename = @"my.cer";
var cert = X509Certificate2.CreateFromCertFile(certFilename);
cert.Import(certFilename, "my pin", X509KeyStorageFlags.Exportable);
request.ClientCertificates.Add(cert);
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();
But I get a 403 Forbidden.
If you are using SharePoint 2010:
What this does is it creates a separate SharePoint site that uses the exact same configuration and content databases, but you can host it elsewhere, and secure it separately. This allows you to have your normal, secure SharePoint instance up which is completely locked down, but simultaneously host another version of it elsewhere that has different security, which you can give other access to, namely your service that needs to run indexes or other jobs.