我有一个承包商创建了测试并将其上传到 VSTS,但现在当我们运行它们时,我们得到:
The request was aborted. Could not create SSL/TLS secure channel.
这是如何解决的?我是 VSTS 的新手。
最佳答案
您的证书有效吗?此错误通常来自无效证书或开发证书,或者来自提供与客户期望的版本不同的 TLS 版本的证书。
根据 this answer on Software QA ,您通常可以通过修改包含在代码中的预测试处理程序插件中的 ServicePointManager
来解决此问题。
请从 the MSDN forums 阅读此示例中的注释- 您应该修改回调函数以对证书执行一些验证以确保它是您期望的环境。
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;
}
}
}
这将需要根据 MSDN documentation on creating Web Test Plugins 添加到您的 Web 测试中.
您将需要遵循类似的过程来创建负载测试插件(而不是继承自 `Microsoft.VisualStudio.TestTools.LoadTesting.ILoadTestPlugin)并遵循 MSDN documentation on creating Load Test Plugins .
关于c# - 使用 Visual Studio Team Services (VSTS) 运行带有 SSL 错误的 Web/负载测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47822386/