From b59da2a95fa20d3b3194ab77b02e2d9df7cf2bbc Mon Sep 17 00:00:00 2001 From: Dorothy Tam Date: Thu, 4 Apr 2019 14:31:41 +1100 Subject: [PATCH 01/12] - Remove minimumSSLProtocol parameter - Set TLSMinimumSupportedProtocol based on ServicePointManager.SecurityProtocol on iOS --- .../iOS/NSUrlSessionHandler.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/ModernHttpClient/iOS/NSUrlSessionHandler.cs b/src/ModernHttpClient/iOS/NSUrlSessionHandler.cs index 610999d..2b406bd 100644 --- a/src/ModernHttpClient/iOS/NSUrlSessionHandler.cs +++ b/src/ModernHttpClient/iOS/NSUrlSessionHandler.cs @@ -54,20 +54,22 @@ public class NativeMessageHandler : HttpClientHandler public bool DisableCaching { get; set; } public NativeMessageHandler(): this(false, false) { } - public NativeMessageHandler(bool throwOnCaptiveNetwork, bool customSSLVerification, NativeCookieHandler cookieHandler = null, SslProtocol? minimumSSLProtocol = null) + public NativeMessageHandler(bool throwOnCaptiveNetwork, bool customSSLVerification, NativeCookieHandler cookieHandler = null) { var configuration = NSUrlSessionConfiguration.DefaultSessionConfiguration; // System.Net.ServicePointManager.SecurityProtocol provides a mechanism for specifying supported protocol types // for System.Net. Since iOS only provides an API for a minimum and maximum protocol we are not able to port // this configuration directly and instead use the specified minimum value when one is specified. - if (minimumSSLProtocol.HasValue) { - configuration.TLSMinimumSupportedProtocol = minimumSSLProtocol.Value; - } - - session = NSUrlSession.FromConfiguration( - NSUrlSessionConfiguration.DefaultSessionConfiguration, - new DataTaskDelegate(this), null); + var sp = ServicePointManager.SecurityProtocol; + if ((sp & SecurityProtocolType.Ssl3) != 0) + configuration.TLSMinimumSupportedProtocol = SslProtocol.Ssl_3_0; + else if ((sp & SecurityProtocolType.Tls) != 0) + configuration.TLSMinimumSupportedProtocol = SslProtocol.Tls_1_0; + else if ((sp & SecurityProtocolType.Tls11) != 0) + configuration.TLSMinimumSupportedProtocol = SslProtocol.Tls_1_1; + else if ((sp & SecurityProtocolType.Tls12) != 0) + configuration.TLSMinimumSupportedProtocol = SslProtocol.Tls_1_2; this.throwOnCaptiveNetwork = throwOnCaptiveNetwork; this.customSSLVerification = customSSLVerification; From 5117f17c8df5c3bfcd1bd7fbb1b152e23d59ef6f Mon Sep 17 00:00:00 2001 From: Dorothy Tam Date: Thu, 4 Apr 2019 14:33:44 +1100 Subject: [PATCH 02/12] Update NSUrlSession.FromConfiguration with INSUrlSessionDelegate parameter, NSUrlSessionDelegate parameter is obsolete --- src/ModernHttpClient/iOS/NSUrlSessionHandler.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ModernHttpClient/iOS/NSUrlSessionHandler.cs b/src/ModernHttpClient/iOS/NSUrlSessionHandler.cs index 2b406bd..4f2c950 100644 --- a/src/ModernHttpClient/iOS/NSUrlSessionHandler.cs +++ b/src/ModernHttpClient/iOS/NSUrlSessionHandler.cs @@ -71,6 +71,9 @@ public NativeMessageHandler(bool throwOnCaptiveNetwork, bool customSSLVerificati else if ((sp & SecurityProtocolType.Tls12) != 0) configuration.TLSMinimumSupportedProtocol = SslProtocol.Tls_1_2; + INSUrlSessionDelegate sessionDelegate = new DataTaskDelegate (this); + session = NSUrlSession.FromConfiguration (NSUrlSessionConfiguration.DefaultSessionConfiguration, sessionDelegate, null); + this.throwOnCaptiveNetwork = throwOnCaptiveNetwork; this.customSSLVerification = customSSLVerification; From f0c3533c26fe4584b3853c7c92d1499d963fbb80 Mon Sep 17 00:00:00 2001 From: Dorothy Tam Date: Thu, 4 Apr 2019 14:42:22 +1100 Subject: [PATCH 03/12] Add resource.designer file to gitignore file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ffac3b9..fe8de75 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ build/ *.xam packages .vs +*Resource.designer.cs From fe644d757fe8cf1977a4f70b069a74ffe55528ce Mon Sep 17 00:00:00 2001 From: Dorothy Tam Date: Thu, 4 Apr 2019 14:49:17 +1100 Subject: [PATCH 04/12] Update makefile to store nuget packages in ~/.local/share/NuGet/Cache/ folder --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f00056e..d8d33c6 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ all: ModernHttpClient.iOS64.dll ModernHttpClient.Android.dll ModernHttpClient.Po package: ModernHttpClient.iOS64.dll ModernHttpClient.Android.dll ModernHttpClient.Portable.dll nuget pack - mv modernhttpclient*.nupkg ./build/ + mv modernhttpclient*.nupkg ~/.local/share/NuGet/Cache/ ModernHttpClient.Android.dll: $(MDTOOL) build -c:Release ./src/ModernHttpClient/ModernHttpClient.Android.csproj From 6cc6250cd4c11fb25369f2d1a74996a0b3beee5f Mon Sep 17 00:00:00 2001 From: Dorothy Tam Date: Thu, 4 Apr 2019 15:36:25 +1100 Subject: [PATCH 05/12] Version bump to 2.6.0 --- ModernHttpClient.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ModernHttpClient.nuspec b/ModernHttpClient.nuspec index fafc804..88e32df 100644 --- a/ModernHttpClient.nuspec +++ b/ModernHttpClient.nuspec @@ -1,7 +1,7 @@ - 2.5.1 + 2.6.0 Switch Media, Paul Betts Switch Media, Paul Betts https://github.com/paulcbetts/ModernHttpClient/blob/master/COPYING From 32dac94bda9eebf69be22d0eaceee2b35b1c8ddb Mon Sep 17 00:00:00 2001 From: Dorothy Tam Date: Fri, 5 Apr 2019 10:27:34 +1100 Subject: [PATCH 06/12] Add version-bump and release-pack targets to makefile --- Makefile | 11 +++++++++++ ModernHttpClient.nuspec | 7 +++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index d8d33c6..0f59036 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,12 @@ MDTOOL ?= /Applications/Visual\ Studio.app/Contents/MacOS/vstool +NUSPEC_FILE ?= ModernHttpClient.nuspec .PHONY: all clean all: ModernHttpClient.iOS64.dll ModernHttpClient.Android.dll ModernHttpClient.Portable.dll +release-pack: version-bump package + package: ModernHttpClient.iOS64.dll ModernHttpClient.Android.dll ModernHttpClient.Portable.dll nuget pack mv modernhttpclient*.nupkg ~/.local/share/NuGet/Cache/ @@ -27,3 +30,11 @@ clean: $(MDTOOL) build -t:Clean ModernHttpClient.sln rm *.dll rm -rf build + +version-bump: + $(eval version = $(shell grep '' $(NUSPEC_FILE) | sed "s@.*\(.*\).*@\1@")) + $(eval majorMinor = $(shell echo $(version) | rev | cut -d'.' -f2- | rev)) + $(eval buildNumber = $(shell echo $(version) | rev | cut -d'.' -f 1 | rev)) + $(eval newVersion = $(majorMinor).$(shell expr $(buildNumber) + 1)) + @echo version updated to $(newVersion) + $(shell xmlstarlet ed -L -N N="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd" -u '/N:package/N:metadata/N:version' -v $(newVersion) $(NUSPEC_FILE)) diff --git a/ModernHttpClient.nuspec b/ModernHttpClient.nuspec index 88e32df..507ee2c 100644 --- a/ModernHttpClient.nuspec +++ b/ModernHttpClient.nuspec @@ -11,15 +11,14 @@ false Write your app using System.Net.Http, but drop this library in and it will go drastically faster. Write your app using System.Net.Http, but drop this library in and it will go drastically faster. - Copyright Paul Betts © 2012 + Copyright Paul Betts © 2012 - + - - + From 652a4057565e2a8e0914696c78f8683590fbab7b Mon Sep 17 00:00:00 2001 From: Dorothy Tam Date: Fri, 5 Apr 2019 11:53:00 +1100 Subject: [PATCH 07/12] Remove version-bump targets in makefile --- Makefile | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Makefile b/Makefile index 0f59036..fbc7f1d 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,6 @@ NUSPEC_FILE ?= ModernHttpClient.nuspec all: ModernHttpClient.iOS64.dll ModernHttpClient.Android.dll ModernHttpClient.Portable.dll -release-pack: version-bump package - package: ModernHttpClient.iOS64.dll ModernHttpClient.Android.dll ModernHttpClient.Portable.dll nuget pack mv modernhttpclient*.nupkg ~/.local/share/NuGet/Cache/ @@ -30,11 +28,3 @@ clean: $(MDTOOL) build -t:Clean ModernHttpClient.sln rm *.dll rm -rf build - -version-bump: - $(eval version = $(shell grep '' $(NUSPEC_FILE) | sed "s@.*\(.*\).*@\1@")) - $(eval majorMinor = $(shell echo $(version) | rev | cut -d'.' -f2- | rev)) - $(eval buildNumber = $(shell echo $(version) | rev | cut -d'.' -f 1 | rev)) - $(eval newVersion = $(majorMinor).$(shell expr $(buildNumber) + 1)) - @echo version updated to $(newVersion) - $(shell xmlstarlet ed -L -N N="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd" -u '/N:package/N:metadata/N:version' -v $(newVersion) $(NUSPEC_FILE)) From d87700e305274b2443f81c3421b4aecacbdcc5b1 Mon Sep 17 00:00:00 2001 From: Dorothy Tam Date: Fri, 5 Apr 2019 11:57:10 +1100 Subject: [PATCH 08/12] Revert whitespace changes in nuspec --- ModernHttpClient.nuspec | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ModernHttpClient.nuspec b/ModernHttpClient.nuspec index 507ee2c..4cb000d 100644 --- a/ModernHttpClient.nuspec +++ b/ModernHttpClient.nuspec @@ -11,14 +11,15 @@ false Write your app using System.Net.Http, but drop this library in and it will go drastically faster. Write your app using System.Net.Http, but drop this library in and it will go drastically faster. - Copyright Paul Betts © 2012 + Copyright Paul Betts © 2012 - + + - + From 531d8a4051fc6f6a86ba54da8557ec1a196c642e Mon Sep 17 00:00:00 2001 From: Dorothy Tam Date: Fri, 5 Apr 2019 12:05:43 +1100 Subject: [PATCH 09/12] Remove Resource.designer.cs file from repo --- .../Resources/Resource.designer.cs | 131 ------------------ 1 file changed, 131 deletions(-) delete mode 100644 src/Playground.Android/Resources/Resource.designer.cs diff --git a/src/Playground.Android/Resources/Resource.designer.cs b/src/Playground.Android/Resources/Resource.designer.cs deleted file mode 100644 index b947db6..0000000 --- a/src/Playground.Android/Resources/Resource.designer.cs +++ /dev/null @@ -1,131 +0,0 @@ -#pragma warning disable 1591 -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 4.0.30319.17020 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -[assembly: Android.Runtime.ResourceDesignerAttribute("Playground.Android.Resource", IsApplication=true)] - -namespace Playground.Android -{ - - - [System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")] - public partial class Resource - { - - static Resource() - { - global::Android.Runtime.ResourceIdManager.UpdateIdValues(); - } - - public static void UpdateIdValues() - { - global::ModernHttpClient.Resource.String.library_name = global::Playground.Android.Resource.String.library_name; - } - - public partial class Attribute - { - - static Attribute() - { - global::Android.Runtime.ResourceIdManager.UpdateIdValues(); - } - - private Attribute() - { - } - } - - public partial class Drawable - { - - // aapt resource value: 0x7f020000 - public const int Icon = 2130837504; - - static Drawable() - { - global::Android.Runtime.ResourceIdManager.UpdateIdValues(); - } - - private Drawable() - { - } - } - - public partial class Id - { - - // aapt resource value: 0x7f050001 - public const int cancelButton = 2131034113; - - // aapt resource value: 0x7f050000 - public const int doIt = 2131034112; - - // aapt resource value: 0x7f050004 - public const int md5sum = 2131034116; - - // aapt resource value: 0x7f050005 - public const int progress = 2131034117; - - // aapt resource value: 0x7f050003 - public const int result = 2131034115; - - // aapt resource value: 0x7f050002 - public const int status = 2131034114; - - static Id() - { - global::Android.Runtime.ResourceIdManager.UpdateIdValues(); - } - - private Id() - { - } - } - - public partial class Layout - { - - // aapt resource value: 0x7f030000 - public const int Main = 2130903040; - - static Layout() - { - global::Android.Runtime.ResourceIdManager.UpdateIdValues(); - } - - private Layout() - { - } - } - - public partial class String - { - - // aapt resource value: 0x7f040002 - public const int app_name = 2130968578; - - // aapt resource value: 0x7f040001 - public const int hello = 2130968577; - - // aapt resource value: 0x7f040000 - public const int library_name = 2130968576; - - static String() - { - global::Android.Runtime.ResourceIdManager.UpdateIdValues(); - } - - private String() - { - } - } - } -} -#pragma warning restore 1591 From d9f61ebb9b70f176c40e92a70df45af3b8adc289 Mon Sep 17 00:00:00 2001 From: Dorothy Tam Date: Fri, 5 Apr 2019 12:11:20 +1100 Subject: [PATCH 10/12] Remove whitespace --- ModernHttpClient.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ModernHttpClient.nuspec b/ModernHttpClient.nuspec index 4cb000d..88e32df 100644 --- a/ModernHttpClient.nuspec +++ b/ModernHttpClient.nuspec @@ -18,7 +18,7 @@ - + From 2dbe73e891b76d5c1f2697f86e397f34a1c57818 Mon Sep 17 00:00:00 2001 From: Dorothy Tam Date: Fri, 5 Apr 2019 12:11:57 +1100 Subject: [PATCH 11/12] Remove NUSPEC_FILE variable --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index fbc7f1d..d8d33c6 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,4 @@ MDTOOL ?= /Applications/Visual\ Studio.app/Contents/MacOS/vstool -NUSPEC_FILE ?= ModernHttpClient.nuspec .PHONY: all clean From 78b4adcae8c6fe2a795f4945ab80ea7f64b38be1 Mon Sep 17 00:00:00 2001 From: Dorothy Tam Date: Fri, 5 Apr 2019 12:14:21 +1100 Subject: [PATCH 12/12] Revert changes to makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d8d33c6..f00056e 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ all: ModernHttpClient.iOS64.dll ModernHttpClient.Android.dll ModernHttpClient.Po package: ModernHttpClient.iOS64.dll ModernHttpClient.Android.dll ModernHttpClient.Portable.dll nuget pack - mv modernhttpclient*.nupkg ~/.local/share/NuGet/Cache/ + mv modernhttpclient*.nupkg ./build/ ModernHttpClient.Android.dll: $(MDTOOL) build -c:Release ./src/ModernHttpClient/ModernHttpClient.Android.csproj