Skip to content
This repository has been archived by the owner on Nov 10, 2020. It is now read-only.

Commit

Permalink
Add and comment out code that bypasses TLS auth.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilfredo Sánchez Vega committed Nov 12, 2015
1 parent 0bb29a8 commit ad72af4
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions Incidents/HTTPSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,27 @@ private class SessionDelegate: NSObject, NSURLSessionTaskDelegate {
)
}

func defaultHandler() {
completionHandler(
NSURLSessionAuthChallengeDisposition.PerformDefaultHandling,
nil
)
}

switch challenge.previousFailureCount {
case 0:
if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust {
// if let trust = challenge.protectionSpace.serverTrust {
// let credential = NSURLCredential(trust: trust)
// return completionHandler(
// NSURLSessionAuthChallengeDisposition.UseCredential,
// credential
// )
// }

// This is a request to authenticate *the server* (eg. it's TLS certificate).
// We'll ask for the default handling of that here.
completionHandler(
NSURLSessionAuthChallengeDisposition.PerformDefaultHandling,
nil
)
return
return defaultHandler()
}

if let lastCredential = lastCredential {
Expand All @@ -233,11 +244,10 @@ private class SessionDelegate: NSObject, NSURLSessionTaskDelegate {

guard let authHandler = self.session?.authHandler else {
// The application did not provide an auth handler; use the default handling.
completionHandler(
return completionHandler(
NSURLSessionAuthChallengeDisposition.PerformDefaultHandling,
nil
)
return
}

logInfo("Authenticating HTTP connection...")
Expand All @@ -255,7 +265,7 @@ private class SessionDelegate: NSObject, NSURLSessionTaskDelegate {
}

logInfo("Unable to authenticate HTTP connection.")
completionHandler(
return completionHandler(
NSURLSessionAuthChallengeDisposition.CancelAuthenticationChallenge,
nil
)
Expand Down

0 comments on commit ad72af4

Please sign in to comment.