In a web application (aspx/C#) that will sign documents, how can I list the certificates located on the user USB key (authentication / signing key) ?
Here is my code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Signature1
{
public partial class signature : System.Web.UI.Page
{
string strTxt = "Certificates : ";
protected void Page_Load(object sender, EventArgs e)
{
X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
foreach (X509Certificate2 cert in store.Certificates)
{
strTxt += "\nDélivered to " + cert.SubjectName.Name + " by " + cert.IssuerName.Name;
}
store.Close();
myTextbox.Text = strTxt ;
}
}
}
This code works fine on the local machine (debug mode) but returns an empty list when published on an application server.
Thank you for your help.