A3 Certificate in ASP.NET MVC and IIS

Asked

Viewed 1,107 times

4

I have an ASP.NET MVC4 application and use the following code to read the A3 certificate (reader or USB stick) of the user:

var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
  store.Open(OpenFlags.OpenExistingOnly | OpenFlags.MaxAllowed);

  var collection = store.Certificates;
  var fcollection = collection.Find(X509FindType.FindByTimeValid, DateTime.Now, true);
  var scollection = X509Certificate2UI.SelectFromCollection(fcollection, "Certificados válidos:", "Selecione o certificado que deseja usar",
            X509SelectionFlag.SingleSelection);

When I am debugging (using Iisexpress) the code works normal, but when I publish the application on IIS 7.5 (on my local machine) returns the following error:

Current session is not interactive.

Question: Is it possible to make OSI "respect" the code on top of it in the same way that Iisexpress does?

1 answer

1


It is possible to make the OSI "respect" the code above in the same way that the IISEXPRESS does?

No. This is not a problem with the OSI. The point is that you are using an A3 Certificate (hence a Smart Card) for authentication, or to sign or encrypt an object.

The problem there is that this data extraction is always local, and IIS is only local at the moment you are developing. In this case, it is best to develop a Smart Card authentication on your system and use its certificate to perform the operations. This article is a little long, but it explains all that I said.

Or, if you just want to extract the certificate using your authentication, you can write an Activex component (which needs to be installed on the user’s machine, therefore) and make this component send the data to your web application. Here is an implementation. Here’s another.

  • Gypsy, the Activex link (https://github.com/cardid/WebCard) you posted would be ideal for me, but I didn’t understand how I could pass an object like X509certificate2ui. You would have some example, if it’s not too much to ask.

  • Already yes, I installed the plugin, but nothing happens. But thanks for the tip, I’ll see the other option, inte!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.