0

我设法在 c#(下面的代码)中创建了加密密钥对话框,并且我得到了响应消息的状态代码 ok。没关系。

但现在我想知道,如果同样的想法可以在 javascript 项目中完成?我更喜欢使用 javascript,因为我无法让 ajax 请求在 c# 中工作(我用它来访问来自 api 的数据)。

        try
        {
            HttpClientHandler aHandler = new HttpClientHandler();
            aHandler.ClientCertificateOptions = ClientCertificateOption.Automatic;

            HttpClient aClient = new HttpClient(aHandler);
            HttpResponseMessage aResp = await aClient.GetAsync("https://www.somelink.com/"); //this is not the link I used
            txtBlock.Text = aResp.StatusCode.ToString();
        }
        catch (Exception theEx)
        {
            txtBlock.Text = theEx.Message;
        }

在此处输入图像描述

4

1 回答 1

0

正如我从这个线程中看到的:

http://social.msdn.microsoft.com/Forums/windowsapps/en-US/0d005703-0ec3-4466-b389-663608fff053/using-client-side-certificates-in-windows-metro?forum=winappswithcsharp

2012 年 9 月 6 日星期四下午 1:15,来自 Gaurav Mantri (MVP)

他尝试在 C# 和 JS 中以程序方式导入证书,在 JS 中他设法做到了这一点,所以如果他需要该证书,那么他会使用它,所以从逻辑上讲 - 在 JS 中是可能的

于 2014-01-10T11:54:23.650 回答