由于我的网站使用ssl证书,因此无法再从服务器访问xml文件。请帮我。
我从ZeroSSL页面获取4个文件:
account-key.txt; (RSA私钥)
domain-csr.txt; (CRT)(CABUNDLE)2OmkvG1CfXtJ-sYpp5mV0 ......; (文件
无扩展名)qGGRddmOl62soMPdlCBeamnR ......; (文件不带
延期)
网址现在以https开头,我当前的代码是:
string currentVersion = GetWebPage("http://sofobot.com/version.xml");
XmlDocument VersionInfo = new XmlDocument();
VersionInfo.LoadXml(currentVersion);
.
.
public static string GetWebPage(string URL)
{
System.Net.HttpWebRequest Request = (HttpWebRequest)(WebRequest.Create(new Uri(URL)));
Request.Method = "GET";
Request.MaximumAutomaticRedirections = 4;
Request.MaximumResponseHeadersLength = 4;
Request.ContentLength = 0;
StreamReader ReadStream = null;
HttpWebResponse Response = null;
string ResponseText = string.Empty;
Response = (HttpWebResponse)(Request.GetResponse());
Stream ReceiveStream = Response.GetResponseStream();
ReadStream = new StreamReader(ReceiveStream, System.Text.Encoding.UTF8);
ResponseText = ReadStream.ReadToEnd();
Response.Close();
ReadStream.Close();
return ResponseText;
}
错误InnerException-> stacktrace:
zh-cn System.Net.Security.SslState.StartReadFrame(Byte [] buffer,Int32 readBytes,AsyncProtocolRequest asyncRequest)
zh-cn System.Net.Security.SslState.StartReceiveBlob(字节[]缓冲区,AsyncProtocolRequest asyncRequest)
zh-cn System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken消息,AsyncProtocolRequest asyncRequest)
zh-cn System.Net.Security.SslState.ForceAuthentication(布尔型receiveFirst,字节[]缓冲区,AsyncProtocolRequest asyncRequest)
zh-cn System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
zh-cn System.Threading.ExecutionContext.RunInternal(ExecutionContext executeContext,ContextCallback回调,对象状态,布尔类型saveSyncCtx)
zh-cn System.Threading.ExecutionContext.Run(ExecutionContext执行上下文,ContextCallback回调,对象状态,布尔值saveSyncCtx)
zh-cn System.Threading.ExecutionContext.Run(ExecutionContext执行上下文,ContextCallback回调,对象状态)
zh-cn System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult结果)
zh-cn System.Net.TlsStream.Write(Byte []缓冲区,Int32偏移量,Int32大小)
zh-cn System.Net.ConnectStream.WriteHeaders(布尔异步)
最佳答案
无需共享您的SSL证书信息。
我认为这可能是一个简单的解决方案
string currentVersion = GetWebPage("http://sofobot.com/version.xml"); // https!
您需要将协议更改为HTTPS而不是使用HTTP
关于c# - C#使用HTTPS从URL读取XML文件。 (与godaddy托管)(来自ZerosSSL的证书),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54240435/