Using Visual Studio Team Services (VSTS) to run web/load testing with SSL error

佐手、 提交于 2019-11-27 08:17:13

问题


I have a contractor who created and uploaded test to VSTS but now when we run them we get:

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

Screen cap of errors

How is this fixed? I am new to VSTS.


回答1:


Is your certificate valid? This error most often comes from an invalid or development certificate, or from a certificate supplying a different TLS version to the one the client is expecting.

According to this answer on Software QA, you can usually work around this by modifying the ServicePointManager in a pre-test handler plugin that you include with your code.

Please read the comments in this example from the MSDN forums - you should modify the call-back function to perform some validation on the certificate to ensure it is the environment you are expecting.

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;
    }
  }
}

This will then need to be added to your Web Test as per the MSDN documentation on creating Web Test Plugins.

You will need to follow a similar process to create a Load Test plug-in (inheriting instead from `Microsoft.VisualStudio.TestTools.LoadTesting.ILoadTestPlugin) and follow the MSDN documentation on creating Load Test Plugins.



来源:https://stackoverflow.com/questions/47822386/using-visual-studio-team-services-vsts-to-run-web-load-testing-with-ssl-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!