[Edit: it should be scriptcs in the subject, not cscript. Has been corrected in the text below]
As most everyone (hopefully), we are phasing out support for TLS 1.0 and 1.1.
One of the few issues we encountered was with Octopus scriptcs which executes C# script step templates. The below is NOT regarding communication between Octopus and server and Calamari tentacles.
For a destination http server where support for TLS 1.0 and 1.1 had been disabled, when doing a (HttpWebResponse)request.GetResponse() it would always fail until we added the * * starred * * line below, which is bad practise because what about when TLS 1.3 becomes final?
#r "C:\Windows\System32\inetsrv/Microsoft.Web.Administration.dll";
string targetWebSite = Octopus.Parameters["TargetWebsite"];
string baseUrl = Octopus.Parameters["LocalBaseUrl"];
// Connect to IIS ServerManager
using (var serverManager = new Microsoft.Web.Administration.ServerManager())
{
* *ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;* *
Microsoft.Web.Administration.Site site = serverManager.Sites[targetWebSite];
if (site != null)
{
foreach (Microsoft.Web.Administration.Application application in site.Applications)
{
try
{
if (application.Path.IndexOf("/api/") != -1)
{
string url = String.Format("{0}{1}/{2}", baseUrl, application.Path, "ourapplication/cache.aspx?inpClearAll=1");
Console.WriteLine("url: {0}", url);
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
request.Method = "POST";
request.ContentLength = 0;
System.Net.HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Console.WriteLine("Web Response Status Code : {0}", response.StatusCode.ToString());
IMHO this shouldn’t be the case and means that Octopus’ included scriptcs is compiled against an older .Net Framework which, although it does support TLS 1.2, doesn’t have it as default or fallback. Which today it should.