I have to use an SSL certificate on the client, using a web page in ASP.NET which is found on an IIS server. To do this I try to open x509store. Everything is fine on the development computer, but if I publish on the IIS server I receive the error: The current session is not interactive. I tried to change your user profile on true, but it doesn't work. I'm not very practical of asp.net and so I don't know what to do, can you help me? Sorry if I'm not very clear, but I can add any information you ask me. This is the code I use and that works on my PC.
public static X509Certificate2 GetCertificate()
{
X509Store x509Store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
X509Certificate2 certSelected = null;
x509Store.Open(OpenFlags.ReadOnly);
X509Certificate2Collection col = x509Store.Certificates;
X509Certificate2Collection sel = X509Certificate2UI.SelectFromCollection(col, "Title", "Message", X509SelectionFlag.SingleSelection);
if (sel.Count > 0)
{
X509Certificate2Enumerator en = sel.GetEnumerator();
en.MoveNext();
certSelected = en.Current;
}
x509Store.Close();
return certSelected;
}