Skip to content

Commit 36e31b8

Browse files
use the HttpRequestMessage as sender for ServicePointManager.ServerCertificateValidationCallback
(it's still not the HttpWebRequest what would be the standard, but better than a simple hostname as string) - just iOS for now
1 parent 6db012c commit 36e31b8

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ build/
66
build/
77
*.xam
88
packages
9+
*.user
10+
*.bak
11+
*.suo

src/ModernHttpClient/iOS/NSUrlSessionHandler.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,6 @@ InflightOperation getResponseForTask(NSUrlSessionTask task)
261261

262262
public override void DidReceiveChallenge(NSUrlSession session, NSUrlSessionTask task, NSUrlAuthenticationChallenge challenge, Action<NSUrlSessionAuthChallengeDisposition, NSUrlCredential> completionHandler)
263263
{
264-
265-
266264
if (challenge.ProtectionSpace.AuthenticationMethod == NSUrlProtectionSpace.AuthenticationMethodNTLM) {
267265
NetworkCredential credentialsToUse;
268266

@@ -337,9 +335,8 @@ public override void DidReceiveChallenge(NSUrlSession session, NSUrlSessionTask
337335
goto sslErrorVerify;
338336
}
339337

340-
sslErrorVerify:
341-
var hostname = task.CurrentRequest.Url.Host;
342-
bool result = ServicePointManager.ServerCertificateValidationCallback(hostname, root, chain, errors);
338+
sslErrorVerify:
339+
bool result = ServicePointManager.ServerCertificateValidationCallback(getResponseForTask(task).Request, root, chain, errors);
343340
if (result) {
344341
completionHandler(
345342
NSUrlSessionAuthChallengeDisposition.UseCredential,

src/Playground.Android/MainActivity.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected override void OnCreate (Bundle bundle)
5858
System.Diagnostics.Debug.WriteLine(el.Certificate.Subject);
5959
}
6060

61-
return true;
61+
return false;
6262
};
6363

6464
// Get our button from the layout resource,
@@ -94,8 +94,8 @@ protected override void OnCreate (Bundle bundle)
9494
try {
9595
//var url = "https://tv.eurosport.com";
9696
//var url = "https://github.com/downloads/nadlabak/android/cm-9.1.0a-umts_sholes.zip";
97-
var url = "https://github.com/paulcbetts/ModernHttpClient/releases/download/0.9.0/ModernHttpClient-0.9.zip";
98-
//var url = "https://self-signed.badssl.com/";
97+
//var url = "https://github.com/paulcbetts/ModernHttpClient/releases/download/0.9.0/ModernHttpClient-0.9.zip";
98+
var url = "https://self-signed.badssl.com/";
9999
//var url = "https://code4ward.ddns.net:54899/status"; // switch to /status once the server has been updated
100100

101101

0 commit comments

Comments
 (0)