在 JavaScript 上请求客户端证书

Mat*_*uba 3 javascript c# asp.net ssl digital-certificate

目标

我需要在浏览器上打开此 JavaScript 证书模态,以便用户选择他们的证书(抱歉,这是葡萄牙语):

在此处输入图片说明

然后Action像这样保存在我的身上:

[HttpGet]
public ActionResult GetClientCertificate() {
    var requestCertificate = System.Web.HttpContext.Current.Request.ClientCertificate;

    ///Transform to byte[] and save on DataBase
}
Run Code Online (Sandbox Code Playgroud)

问题

我花了很多时间研究,因为这是我第一次接触这种技术,但不管我做什么,我都无法让它发挥作用。模态永远不会打开并且ClientCertificate总是空的。真的有可能在 JavaScript 上实现这一目标吗?

语境

ISS配置

<access sslFlags="SslNegotiateCert" />

<applicationDependencies>
    <application name="Active Server Pages" groupId="ASP" />
</applicationDependencies>

<authentication>

    <anonymousAuthentication enabled="true" userName="" />

    <basicAuthentication enabled="false" />

    <clientCertificateMappingAuthentication enabled="true" />

    <digestAuthentication enabled="false" />

    <iisClientCertificateMappingAuthentication enabled="true">
    </iisClientCertificateMappingAuthentication>

    <windowsAuthentication enabled="false">
        <providers>
            <add value="Negotiate" />
            <add value="NTLM" />
        </providers>
    </windowsAuthentication>

</authentication>

<authorization>
    <add accessType="Allow" users="*" />
</authorization>
Run Code Online (Sandbox Code Playgroud)

JS

$(document).on("click", "#btnCertificate", function() {
    $.get("/Gerenciamento/CertificadoDigital/GetCertificate", null, function(data) {
        //// Redirect to other page
    });
});
Run Code Online (Sandbox Code Playgroud)

链接

这是我到目前为止似乎遇到的问题(有一半没有回答):

Mat*_*uba 6

经过大量研究(并在@pedrofb的帮助下),我发现不可能通过Ajax(或JavaScript)触发Prompt Requesting Client Certificate ,必须让服务器配置通过url触发它,导致我改变我对此的看法。

我通过要求用户上传证书的.pptx文件以将其作为保存在我们的数据库中来解决它,以便稍后我需要将其转换为X509Certificate