locked
read from certificate store RRS feed

  • Question

  • User-1293916390 posted

    I can create a console application and read from the user windows certificate store:

    X509Store st;
                X509Certificate2Collection col;            
                st = new X509Store(StoreName.My);
                st.Open(OpenFlags.ReadOnly);
                col = X509Certificate2UI.SelectFromCollection(st.Certificates, "Certificates list", "Select certificate", X509SelectionFlag.SingleSelection);

    This does not work in asp.net IIS, throws an exception: The current session is not interactive.

    Is there a way to do it in asp.net, or do I have to create an activex/client side type of application?

    thanks.

    Thursday, January 28, 2016 5:49 PM

Answers

  • User-718146471 posted

    Here is a stackoverflow discussion that explains this much better than I can and it seems to have a solution to make it work:

    http://stackoverflow.com/questions/14933477/client-authentication-via-x509-certificates-in-asp-net

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 28, 2016 6:10 PM
  • User-986267747 posted

    Hi psei,

    This does not work in asp.net IIS, throws an exception: The current session is not interactive.

    IIS is not allowed to interact with your graphical system. You are using X509Certificate2UI, which can only be used in an interactive application, like Windows Form application. This function displays user interface dialogs that allow you to select and view X.509 certificates. This can’t be used in asp.net web application.

    While running the application in Cassani server or Visual studio environment, it ran as an interactive application and hence the dialog was opening, but when hosted on IIS it behaves as web application and hence would not show the dialog.

    As an alternate to it, you can develop an Windows Application, which would be distributed to the stake holders for digital signing of the documents locally on their system.

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/7fe93f58-bfa6-4e54-ba0a-b07274bf215b/x509certificate2ui-problem?forum=netfxbcl

    Best Regards,

    Klein zhang

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 29, 2016 4:46 AM

All replies

  • User-718146471 posted

    Here is a stackoverflow discussion that explains this much better than I can and it seems to have a solution to make it work:

    http://stackoverflow.com/questions/14933477/client-authentication-via-x509-certificates-in-asp-net

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 28, 2016 6:10 PM
  • User-986267747 posted

    Hi psei,

    This does not work in asp.net IIS, throws an exception: The current session is not interactive.

    IIS is not allowed to interact with your graphical system. You are using X509Certificate2UI, which can only be used in an interactive application, like Windows Form application. This function displays user interface dialogs that allow you to select and view X.509 certificates. This can’t be used in asp.net web application.

    While running the application in Cassani server or Visual studio environment, it ran as an interactive application and hence the dialog was opening, but when hosted on IIS it behaves as web application and hence would not show the dialog.

    As an alternate to it, you can develop an Windows Application, which would be distributed to the stake holders for digital signing of the documents locally on their system.

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/7fe93f58-bfa6-4e54-ba0a-b07274bf215b/x509certificate2ui-problem?forum=netfxbcl

    Best Regards,

    Klein zhang

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 29, 2016 4:46 AM