首页 新闻 会员 周边

访问要证书签名的接口时总是弹出烦人的密码输入对话框的问题

1
悬赏园豆:200 [待解决问题]

最近在做一个数据对接业务,对方接口安全性要求很高,接口需要使用证书私钥进行签名。每次访问接口都会被要求输入证书私钥密码,浏览器访问还能忍受,但是访问接口也会弹框(如图所示)实在不能忍(PS:客户也不接受)。

问题:请问各位大神,如何才能默认输入密码,不要弹框?

现有代码如下:

static string Request()

    {
        try
        {
            StreamReader sr = null;
            HttpWebResponse wr = null;

            HttpWebRequest hp = (HttpWebRequest)WebRequest.Create("https://URL?dataId=0&resType=xml");
            ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);

            var cert = new X509Certificate2("******有限公司_签名证书.cer", "12345678", X509KeyStorageFlags.DefaultKeySet| X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet);
            cert.PrivateKey = AsymmetricAlgorithm.Create("12345678");
            hp.ClientCertificates.Add(cert);

            wr = (HttpWebResponse)hp.GetResponse();
            sr = new StreamReader(wr.GetResponseStream(), System.Text.Encoding.GetEncoding("GBK"));

            return sr.ReadToEnd();
        }
        catch (Exception ex)
        {
            Console.Write("错误:{0}", JsonConvert.SerializeObject(ex));
        }

        return "";
    }
俗世人的主页 俗世人 | 初学一级 | 园豆:2
提问于:2021-07-20 10:40
< >
分享
所有回答(2)
0

不知道autoit能不能解决这个问题

顾晓北 | 园豆:10844 (专家六级) | 2021-07-20 10:57
0
czd890 | 园豆:14412 (专家六级) | 2021-07-20 11:57
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册