C# 来自Windows服务的安全连接错误

C# 来自Windows服务的安全连接错误,c#,ssl,service,client-certificates,C#,Ssl,Service,Client Certificates,我有一个windows服务,它正在将数据发送到一个安全的网页。这在通过VisualStudio2010运行的控制台应用程序中目前运行良好。我已经能够使用这种方法连接和发送数据 问题出现在我部署和运行windows服务时,我现在收到以下错误“请求已中止:无法创建SSL/TLS安全通道” 这是我用来向网页发送http帖子的代码 ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = Se

我有一个windows服务,它正在将数据发送到一个安全的网页。这在通过VisualStudio2010运行的控制台应用程序中目前运行良好。我已经能够使用这种方法连接和发送数据

问题出现在我部署和运行windows服务时,我现在收到以下错误“请求已中止:无法创建SSL/TLS安全通道”

这是我用来向网页发送http帖子的代码

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连接是否还有其他方面不同于窗口服务?如果有人遇到类似的行为,问题就会出现,因为Windows服务没有足够的权限。只有当服务以我自己的身份登录时,它才能在我的本地机器上工作。只有当windows服务以管理员身份登录时,它才能在单独的服务器上工作