来自 Windows 服务的安全连接错误
Secure connection errors from a Windows Service
我有一项 windows 服务正在将数据发送到安全网页。这目前在 运行 到 visual studio 2010 的控制台应用程序中工作正常。我已经能够使用这种方法连接和发送数据。
当我部署 运行 windows 服务时出现问题,我现在收到以下错误 "The request was aborted: Could not create SSL/TLS secure channel."
这是我用来制作网页 post 的代码
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
ServicePointManager.ServerCertificateValidationCallback +=
(sender, cert, chain, sslPolicyErrors) => true;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.ContentType = "text/xml; encoding='utf-8'";
request.Method = "POST";
doc.Save(request.GetRequestStream());
X509Store store = new X509Store(StoreName.Root, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
var certif = store.Certificates.Find(X509FindType.FindByThumbprint, "539B640BD981BFC48A366B8981B66F301C8A3959", false);
request.ClientCertificates.Add(certif);
try
{
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
if (response.StatusCode == HttpStatusCode.OK)
{
success = true;
}
}
}
catch (Exception ex)
{
error = ex.Message + " " + ex.InnerException;
}
我检查了证书库,正确的证书在 windows 服务的受信任根中。 TLS/SSL 连接是否有不同于 Window 服务的另一个方面?任何人有任何想法将不胜感激。
如果有人遇到类似的行为,问题就出现了,因为 Windows 服务没有足够的权限。如果该服务以我自己的身份登录,它只适用于我的本地机器。当 windows 服务以管理员身份登录时,它仅在单独的服务器上工作。
我有一项 windows 服务正在将数据发送到安全网页。这目前在 运行 到 visual studio 2010 的控制台应用程序中工作正常。我已经能够使用这种方法连接和发送数据。
当我部署 运行 windows 服务时出现问题,我现在收到以下错误 "The request was aborted: Could not create SSL/TLS secure channel."
这是我用来制作网页 post 的代码
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
ServicePointManager.ServerCertificateValidationCallback +=
(sender, cert, chain, sslPolicyErrors) => true;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.ContentType = "text/xml; encoding='utf-8'";
request.Method = "POST";
doc.Save(request.GetRequestStream());
X509Store store = new X509Store(StoreName.Root, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
var certif = store.Certificates.Find(X509FindType.FindByThumbprint, "539B640BD981BFC48A366B8981B66F301C8A3959", false);
request.ClientCertificates.Add(certif);
try
{
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
if (response.StatusCode == HttpStatusCode.OK)
{
success = true;
}
}
}
catch (Exception ex)
{
error = ex.Message + " " + ex.InnerException;
}
我检查了证书库,正确的证书在 windows 服务的受信任根中。 TLS/SSL 连接是否有不同于 Window 服务的另一个方面?任何人有任何想法将不胜感激。
如果有人遇到类似的行为,问题就出现了,因为 Windows 服务没有足够的权限。如果该服务以我自己的身份登录,它只适用于我的本地机器。当 windows 服务以管理员身份登录时,它仅在单独的服务器上工作。