Skip to content

Commit d21dbca

Browse files
Created configuration to disable or enable ssl pinning (#461)
1 parent 4633170 commit d21dbca

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

Sources/Kommunicate/Classes/DataLoader.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ class DataLoader {
2323

2424
// set up the session
2525
let config = URLSessionConfiguration.default
26-
let session = URLSession(
27-
configuration: config,
28-
delegate: KMURLSessionPinningDelegate(),
29-
delegateQueue: nil
30-
)
26+
let session: URLSession = {
27+
if Kommunicate.isKMSSLPinningEnabled {
28+
return URLSession(configuration: config, delegate: KMURLSessionPinningDelegate(), delegateQueue: nil)
29+
} else {
30+
return URLSession(configuration: config)
31+
}
32+
}()
3133

3234
// make the request
3335
let task = session.dataTask(with: urlRequest) {

Sources/Kommunicate/Classes/Kommunicate.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ open class Kommunicate: NSObject, Localizable {
8383
config.chatBar.optionsToShow = .some([.camera, .location, .gallery, .video, .document])
8484
return config
8585
}()
86+
87+
public static var isKMSSLPinningEnabled: Bool = false
8688

8789
/// Configuration which defines the behavior of ConversationView components.
8890
public static var kmConversationViewConfiguration = KMConversationViewConfiguration()
@@ -213,6 +215,7 @@ open class Kommunicate: NSObject, Localizable {
213215
assertionFailure("Kommunicate App ID: Empty value passed")
214216
return
215217
}
218+
ALUserDefaultsHandler.setKMSSLPinningEnabled(isKMSSLPinningEnabled)
216219
guard KMUserDefaultHandler.isAppIdEmpty ||
217220
KMUserDefaultHandler.matchesCurrentAppId(applicationId)
218221
else {

0 commit comments

Comments
 (0)