我在尝试联系安全的休息URL时遇到了实际问题。基本上,我对证书知之甚少,并且想知道我对证书文件所做的操作是否正确。
运行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
...
编辑:目前,我仅尝试“读取” URL-似乎合乎逻辑。
与发行人联系以获取.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."
-重新发布评论作为答案-
要使用此密码,必须输入密码。
它与.p12
文件同时创建。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句