我在尝试联系安全的其他网址时遇到了实际问题。基本上我对证书知之甚少,并且想知道我对证书文件的处理是否正确。
运行req.GetResponse()时会发生异常:
"The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."
Inner Ex: "The remote certificate is invalid according to the validation procedure."
我目前不确定是否需要进行一些修修补补,或者我只是暂时离开。 代码基本上就是......
if (!File.Exists(certificateLocation))
{
throw new Exception(string.Format("The specified certificate file does not exist: {0}", certificateLocation));
}
//Cert Challenge URL
Uri requestURI = new Uri(url);
//Create the Request Object
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requestURI);
//Set the Request Object parameters
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
req.AllowAutoRedirect = false;
//Create certificate from our file
X509Certificate cert = X509Certificate.CreateFromCertFile(certificateLocation);
req.ClientCertificates.Add(cert);
WebResponse response = req.GetResponse(); // *** Errors here
...
编辑:目前我只是尝试“阅读”网址 - 似乎合乎逻辑。
在与发卡行联系以获取.p12证书附带的密码并将其导入认证管理器的“受信任的根证书颁发机构”部分后,错误现已更改为以下内容...
System.Net.WebException
"The underlying connection was closed: An unexpected error occurred on a receive."
Inner Ex:
"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."
答案 0 :(得分:1)
- 将评论重新发布为答案 -
此密码是必须的。
它与.p12
文件同时创建。