From 76346ce106f4e6034e1325463d8aa14018238491 Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Fri, 23 Mar 2018 09:48:29 -0400 Subject: [PATCH 1/7] Update Project for Delphi 10.2.3 --- Delphi/Project/ExercismCLIInstaller.dproj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Delphi/Project/ExercismCLIInstaller.dproj b/Delphi/Project/ExercismCLIInstaller.dproj index f809d06..d86d894 100644 --- a/Delphi/Project/ExercismCLIInstaller.dproj +++ b/Delphi/Project/ExercismCLIInstaller.dproj @@ -1,7 +1,7 @@  {F8605FE1-AB97-4531-9853-D43F5A666830} - 18.3 + 18.4 VCL ExercismCLIInstaller.dpr True @@ -93,8 +93,8 @@ true true true - CompanyName=Exercism;FileDescription=$(MSBuildProjectName);FileVersion=2.0.1.14;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=2.0.1.0;Comments= - 14 + CompanyName=Exercism;FileDescription=$(MSBuildProjectName);FileVersion=2.0.1.15;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=2.0.1.0;Comments= + 15 1 @@ -109,9 +109,9 @@ true 2 true - CompanyName=Exercism;FileDescription=$(MSBuildProjectName);FileVersion=2.0.2.11;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=2.0.2.0;Comments= + CompanyName=Exercism;FileDescription=$(MSBuildProjectName);FileVersion=2.0.2.13;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=2.0.2.0;Comments= img\ExercismCLIInstaller_Icon.ico - 11 + 13 2 From 8e0bbfdd7745827c2afcfeb9d0c8f1a0906d7690 Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Sat, 24 Mar 2018 23:01:49 -0400 Subject: [PATCH 2/7] add REST components Components used to check TLS version of host computer via REST --- Delphi/Project/Source/uInstallLocationFrm.dfm | 24 +++++++++++++++++++ Delphi/Project/Source/uInstallLocationFrm.pas | 6 ++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Delphi/Project/Source/uInstallLocationFrm.dfm b/Delphi/Project/Source/uInstallLocationFrm.dfm index 3f117c3..e3517e5 100644 --- a/Delphi/Project/Source/uInstallLocationFrm.dfm +++ b/Delphi/Project/Source/uInstallLocationFrm.dfm @@ -211,4 +211,28 @@ object frmInstallLocation: TfrmInstallLocation TabOrder = 4 OnClick = btnBrowseClick end + object rcCheckTLSVersion: TRESTClient + Accept = 'application/json, text/plain; q=0.9, text/html;q=0.8,' + AcceptCharset = 'UTF-8, *;q=0.8' + BaseURL = 'https://www.howsmyssl.com/a/check' + Params = <> + HandleRedirects = True + RaiseExceptionOn500 = False + Left = 248 + Top = 48 + end + object rrCheckTLSVersion: TRESTRequest + Client = rcCheckTLSVersion + Params = <> + Response = rResponseCheckTLSVersion + SynchronizedEvents = False + Left = 328 + Top = 52 + end + object rResponseCheckTLSVersion: TRESTResponse + ContentType = 'application/json' + RootElement = 'tls_version' + Left = 416 + Top = 48 + end end diff --git a/Delphi/Project/Source/uInstallLocationFrm.pas b/Delphi/Project/Source/uInstallLocationFrm.pas index 7cb81ff..f5828aa 100644 --- a/Delphi/Project/Source/uInstallLocationFrm.pas +++ b/Delphi/Project/Source/uInstallLocationFrm.pas @@ -5,7 +5,8 @@ interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, uTypes, Vcl.StdCtrls, Vcl.ExtCtrls, - Vcl.Imaging.pngimage, System.UITypes, ovcurl; + Vcl.Imaging.pngimage, System.UITypes, ovcurl, IPPeerClient, REST.Client, + Data.Bind.Components, Data.Bind.ObjectScope; type TfrmInstallLocation = class(TForm) @@ -21,6 +22,9 @@ TfrmInstallLocation = class(TForm) Label5: TLabel; OvcURL4: TOvcURL; Image1: TImage; + rcCheckTLSVersion: TRESTClient; + rrCheckTLSVersion: TRESTRequest; + rResponseCheckTLSVersion: TRESTResponse; procedure btnCancelClick(Sender: TObject); procedure btnNextClick(Sender: TObject); procedure btnBrowseClick(Sender: TObject); From f64a660ef18a849492889b2ebc7b5ae8697fed35 Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Sat, 24 Mar 2018 23:05:42 -0400 Subject: [PATCH 3/7] Add class to check TLS FormActivate triggers check of TLS via REST. --- Delphi/Project/Source/uInstallLocationFrm.dfm | 1 + Delphi/Project/Source/uInstallLocationFrm.pas | 97 +++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/Delphi/Project/Source/uInstallLocationFrm.dfm b/Delphi/Project/Source/uInstallLocationFrm.dfm index e3517e5..f76cc89 100644 --- a/Delphi/Project/Source/uInstallLocationFrm.dfm +++ b/Delphi/Project/Source/uInstallLocationFrm.dfm @@ -15,6 +15,7 @@ object frmInstallLocation: TfrmInstallLocation Font.Style = [] OldCreateOrder = False Position = poScreenCenter + OnActivate = FormActivate OnCreate = FormCreate PixelsPerInch = 96 TextHeight = 13 diff --git a/Delphi/Project/Source/uInstallLocationFrm.pas b/Delphi/Project/Source/uInstallLocationFrm.pas index f5828aa..c54fb36 100644 --- a/Delphi/Project/Source/uInstallLocationFrm.pas +++ b/Delphi/Project/Source/uInstallLocationFrm.pas @@ -9,6 +9,39 @@ interface Data.Bind.Components, Data.Bind.ObjectScope; type + ICheckTLS = interface(IInvokable) + ['{2AED8C0C-BF88-4A06-A3B2-418799CD28EF}'] + function GetTLSOK: boolean; + function GetStatusCode: integer; + function GetTLSVersion: string; + function GetMessageStr: string; + property TLSok: boolean read GetTLSOK; + property StatusCode: integer read GetStatusCode; + property TLSVersion: string read GetTLSVersion; + property ErrMessage: string read GetMessageStr; + end; + + TCheckTLS = class(TInterfacedObject, ICheckTLS) + strict private + const + cDesiredVersion: double = 1.2; + var + fTLSVersion: string; + fTLSOK: boolean; + fStatusCode: integer; + fMessageStr: string; + function GetTLSOK: boolean; + function GetStatusCode: integer; + function GetTLSVersion: string; + function GetMessageStr: string; + public + constructor Create(aRESTRequest: TRestRequest; aRESTResponse: TRESTResponse); + property TLSok: boolean read GetTLSOK; + property StatusCode: integer read GetStatusCode; + property TLSVersion: string read GetTLSVersion; + property ErrMessage: string read GetMessageStr; + end; + TfrmInstallLocation = class(TForm) Panel1: TPanel; Label1: TLabel; @@ -29,6 +62,7 @@ TfrmInstallLocation = class(TForm) procedure btnNextClick(Sender: TObject); procedure btnBrowseClick(Sender: TObject); procedure FormCreate(Sender: TObject); + procedure FormActivate(Sender: TObject); private { Private declarations } public @@ -114,10 +148,73 @@ procedure TfrmInstallLocation.btnNextClick(Sender: TObject); end; end; +procedure TfrmInstallLocation.FormActivate(Sender: TObject); +var + CheckTLS: ICheckTLS; +begin + CheckTLS := TCheckTLS.Create(rrCheckTLSVersion, rResponseCheckTLSVersion); + btnNext.Enabled := CheckTLS.TLSok; + if not btnNext.Enabled then + begin + lblUpdateTLS.Visible := true; + MessageDlg(CheckTLS.ErrMessage,mtError,[mbok],0); + end; +end; + procedure TfrmInstallLocation.FormCreate(Sender: TObject); begin NextClicked := false; SetWindowLong(Handle, GWL_EXSTYLE, WS_EX_APPWINDOW); end; +{ TCheckTLS } + +constructor TCheckTLS.Create(aRESTRequest: TRestRequest; aRESTResponse: TRESTResponse); +var + splitVersion: TArray; + actualVersion: double; +begin + aRESTRequest.Execute; + fStatusCode := aRESTResponse.StatusCode; + fMessageStr := ''; + fTLSOK := false; + fTLSVersion := ''; + if fStatusCode = 200 then + begin + fTLSVersion := aRESTResponse.JSONText.Replace('"',''); + splitVersion := fTLSVersion.Split([' ']); + actualVersion := splitVersion[1].ToDouble; + fTLSOK := actualVersion >= cDesiredVersion; + if not fTLSOK then + fMessageStr := format('TLS Version = %s, must be %0.1f or greater.'+#13#10+ + 'GitHub requires at least version 1.2'+#13#10+ + 'Please follow the link to Microsoft for instructions on updating Windows.',[splitVersion[1],cDesiredVersion]); + end + else + begin + fMessageStr := format('Err: REST Status Code %d', [fStatusCode]); + fTLSOk := false; + end; +end; + +function TCheckTLS.GetMessageStr: string; +begin + result := fMessageStr; +end; + +function TCheckTLS.GetStatusCode: integer; +begin + result := fStatusCode; +end; + +function TCheckTLS.GetTLSOK: boolean; +begin + result := fTLSOk; +end; + +function TCheckTLS.GetTLSVersion: string; +begin + result := fTLSVersion; +end; + end. From 9b1b247e2c01b6dbbd313abc202d4d752d0a1749 Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Sat, 24 Mar 2018 23:09:59 -0400 Subject: [PATCH 4/7] Add url Label This label is is made visible of the TLS version is less than 1.2. The url will open web browser when clicked and open Microsfot page with instructions on how to update TLS settings. --- Delphi/Project/Source/uInstallLocationFrm.dfm | 23 +++++++++++++++++++ Delphi/Project/Source/uInstallLocationFrm.pas | 1 + 2 files changed, 24 insertions(+) diff --git a/Delphi/Project/Source/uInstallLocationFrm.dfm b/Delphi/Project/Source/uInstallLocationFrm.dfm index f76cc89..370faa3 100644 --- a/Delphi/Project/Source/uInstallLocationFrm.dfm +++ b/Delphi/Project/Source/uInstallLocationFrm.dfm @@ -71,6 +71,29 @@ object frmInstallLocation: TfrmInstallLocation ShowHint = True Transparent = True end + object lblUpdateTLS: TOvcURL + Left = 189 + Top = 248 + Width = 262 + Height = 13 + Hint = + 'https://support.microsoft.com/en-us/help/3140245/update-to-enabl' + + 'e-tls-1-1-and-tls-1-2-as-a-default-secure-protocols-in' + Caption = 'Microsoft instructions for updating default TLS settings' + URL = + 'https://support.microsoft.com/en-us/help/3140245/update-to-enabl' + + 'e-tls-1-1-and-tls-1-2-as-a-default-secure-protocols-in' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsUnderline] + ParentFont = False + ParentShowHint = False + ShowHint = True + Transparent = True + Visible = False + end object Panel1: TPanel Left = 0 Top = 0 diff --git a/Delphi/Project/Source/uInstallLocationFrm.pas b/Delphi/Project/Source/uInstallLocationFrm.pas index c54fb36..ccf545f 100644 --- a/Delphi/Project/Source/uInstallLocationFrm.pas +++ b/Delphi/Project/Source/uInstallLocationFrm.pas @@ -58,6 +58,7 @@ TfrmInstallLocation = class(TForm) rcCheckTLSVersion: TRESTClient; rrCheckTLSVersion: TRESTRequest; rResponseCheckTLSVersion: TRESTResponse; + lblUpdateTLS: TOvcURL; procedure btnCancelClick(Sender: TObject); procedure btnNextClick(Sender: TObject); procedure btnBrowseClick(Sender: TObject); From 15d89b9d6a28d26cee83e4653ac9f9c8c116a476 Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Sat, 24 Mar 2018 23:11:32 -0400 Subject: [PATCH 5/7] set btnNext default to disabled btnNext is only enabled if TLS version is sufficient. --- Delphi/Project/Source/uInstallLocationFrm.dfm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Delphi/Project/Source/uInstallLocationFrm.dfm b/Delphi/Project/Source/uInstallLocationFrm.dfm index 370faa3..885ffb2 100644 --- a/Delphi/Project/Source/uInstallLocationFrm.dfm +++ b/Delphi/Project/Source/uInstallLocationFrm.dfm @@ -1,7 +1,6 @@ object frmInstallLocation: TfrmInstallLocation Left = 0 Top = 0 - ActiveControl = btnNext BorderIcons = [] BorderStyle = bsDialog Caption = 'Exercism CLI Install' @@ -209,6 +208,7 @@ object frmInstallLocation: TfrmInstallLocation Width = 75 Height = 25 Caption = '&Next >' + Enabled = False TabOrder = 2 OnClick = btnNextClick end From 473e9c515ad1f64e98d975c355f315d4ed7e18cc Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Sun, 25 Mar 2018 13:23:21 -0400 Subject: [PATCH 6/7] add .~dsk to ignore list --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index a2c9090..62b6338 100644 --- a/.gitignore +++ b/.gitignore @@ -264,3 +264,5 @@ paket-files/ *.vlb *.dsk + +*.~dsk From 6073a7d194bbbff315265b2f4e6640cf317aad24 Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Sun, 25 Mar 2018 13:24:34 -0400 Subject: [PATCH 7/7] release version built --- Delphi/Project/ExercismCLIInstaller.dproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Delphi/Project/ExercismCLIInstaller.dproj b/Delphi/Project/ExercismCLIInstaller.dproj index d86d894..5926f87 100644 --- a/Delphi/Project/ExercismCLIInstaller.dproj +++ b/Delphi/Project/ExercismCLIInstaller.dproj @@ -109,9 +109,9 @@ true 2 true - CompanyName=Exercism;FileDescription=$(MSBuildProjectName);FileVersion=2.0.2.13;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=2.0.2.0;Comments= + CompanyName=Exercism;FileDescription=$(MSBuildProjectName);FileVersion=2.0.2.14;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=2.0.2.0;Comments= img\ExercismCLIInstaller_Icon.ico - 13 + 14 2