使用Visual Studio Team Services(VSTS)以SSL错误运行Web /负载测试

我有一个承包商创建并上传测试到VSTS但现在当我们运行它们时,我们得到:

The request was aborted. Could not create SSL/TLS secure channel. 

屏幕上的错误

这是如何解决的? 我是VSTS的新手。

你的证书有效吗? 此错误通常来自无效或开发证书,或来自提供与客户端期望的TLS版本不同的TLS版本的证书。

根据软件质量保证的答案 ,您通常可以通过在代码中包含的预测试处理程序插件中修改ServicePointManager来解决此问题。

请阅读MSDN论坛中此示例中的注释 – 您应修改回调函数以对证书执行某些validation,以确保它是您期望的环境。

 using System; using System.ComponentModel; using System.Net; using System.Net.Security; using System.Security.Cryptography.X509Certificates; using Microsoft.VisualStudio.TestTools.WebTesting; namespace ExperimentalTesting { [Description("This plugin will force the underlying System.Net ServicePointManager to negotiate downlevel SSLv3 instead of TLS. WARNING: The servers X509 Certificate will be ignored as part of this process, so verify that you are testing the correct system.")] public class SSLv3ForcedPlugin : WebTestPlugin { [Description("Enable or Disable the plugin functionality")] [DefaultValue(true)] public bool Enabled {get;set;} public override void PreWebTest(object sender, PreWebTestEventArgs e) { base.PreWebTest(sender, e); // We're using SSL3 here and not TLS. Update as required. // Without this line, nothing works. ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3; // Wire up the callback so we can override behaviour and force it to // accept the certificate ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCB; // Log the changes to the service point manager e.WebTest.AddCommentToResult(this.ToString() + " has made the following modification-> ServicePointManager.SecurityProtocol set to use SSLv3 in WebTest Plugin."); } public static bool RemoteCertificateValidationCB(Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { // Validate the certificate issuer here // (at least check the O, L, C values, better yet the signature). // Returning true will accept any certificate return true; } } } 

然后,需要根据有关创建Web测试插件的MSDN文档将其添加到Web测试中 。

您需要按照类似的过程创建一个Load Test插件(inheritance自Microsoft.VisualStudio.TestTools.LoadTesting.ILoadTestPlugin),并按照MSDN文档创建Load Test Plugins 。