-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Team Mobile Schorsch
committed
Nov 27, 2024
1 parent
ac09bb4
commit a7932fd
Showing
17 changed files
with
426 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
Sources/GiniHealthAPILibrary/Documents/Core/SSLPinning/GiniSessionDelegate.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// GiniSessionDelegate.swift | ||
// | ||
// | ||
// Copyright © 2024 Gini GmbH. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
/// A delegate for URLSession that implements SSL pinning using the provided SSLPinningManager. | ||
class GiniSessionDelegate: NSObject, URLSessionDelegate { | ||
|
||
/// The manager responsible for validating SSL certificates. | ||
private let pinningManager: SSLPinningManager | ||
|
||
/// Initializes the GiniSessionDelegate with a given SSL pinning configuration. | ||
/// | ||
/// - Parameter pinningConfig: A dictionary containing the pinning configuration, typically mapping domain names to their expected certificate fingerprints. | ||
internal init(pinningConfig: [String: [String]]) { | ||
self.pinningManager = SSLPinningManager(pinningConfig: pinningConfig) | ||
} | ||
|
||
/// Handles the URLSession authentication challenge by delegating the validation to the pinning manager. | ||
/// | ||
/// - Parameters: | ||
/// - session: The URLSession that received the challenge. | ||
/// - challenge: The authentication challenge that needs to be handled. | ||
/// - completionHandler: A completion handler that must be called with the disposition and credential to use for the challenge. | ||
func urlSession(_ session: URLSession, | ||
didReceive challenge: URLAuthenticationChallenge, | ||
completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { | ||
pinningManager.validate(challenge: challenge, completionHandler: completionHandler) | ||
} | ||
} |
Oops, something went wrong.