该请求被中止:无法在CSOM中创建SSL/TLS安全通道

发布于 2025-01-31 13:33:52 字数 1480 浏览 4 评论 0原文

在以下错误之下,请建议任何解决方案。

该请求被中止:无法在Windows Server2012 R2上创建SSL/TLS Secure Channel 。在ClientContext.executequery上。

CSOM SharePoint的代码:

ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                   | SecurityProtocolType.Tls11
                   | SecurityProtocolType.Tls12
                   | SecurityProtocolType.Ssl3;

using (ClientContext ctx = new ClientContext("test.SharePoint.Com"))
            {

                try
                {
                    ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;

                    ctx.AuthenticationMode = ClientAuthenticationMode.Default;
                    SecureString securePassword = new SecureString();
                    foreach (char c in "test")
                        securePassword.AppendChar(c);

                    ctx.Credentials = new SharePointOnlineCredentials("test.com", securePassword);
                    Web web = ctx.Web;
                    ctx.Load(web);
                    ctx.ExecuteQuery(); //The request was aborted: Could not create SSL/TLS secure channel.
                    Console.WriteLine("The web site title: " + web.Title);
                    Console.Read();
                }
                catch(Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

谢谢。

Getting below error, Please suggest any solution.

The request was aborted: Could not create SSL/TLS secure channel on windows server2012 R2. at clientContext.ExecuteQuery.

Code for CSOM SharePoint:

ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                   | SecurityProtocolType.Tls11
                   | SecurityProtocolType.Tls12
                   | SecurityProtocolType.Ssl3;

using (ClientContext ctx = new ClientContext("test.SharePoint.Com"))
            {

                try
                {
                    ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;

                    ctx.AuthenticationMode = ClientAuthenticationMode.Default;
                    SecureString securePassword = new SecureString();
                    foreach (char c in "test")
                        securePassword.AppendChar(c);

                    ctx.Credentials = new SharePointOnlineCredentials("test.com", securePassword);
                    Web web = ctx.Web;
                    ctx.Load(web);
                    ctx.ExecuteQuery(); //The request was aborted: Could not create SSL/TLS secure channel.
                    Console.WriteLine("The web site title: " + web.Title);
                    Console.Read();
                }
                catch(Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文