diff --git a/README.md b/README.md index 24abd82d..45b110e4 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ Alternatively, the pinning policy can be set programmatically: } }}; - [TrustKit initializeWithConfiguration:trustKitConfig]; + [TrustKit initSharedInstanceWithConfiguration:trustKitConfig]; ``` The policy can also be set programmatically in Swift Apps: @@ -83,7 +83,7 @@ The policy can also be set programmatically in Swift Apps: "WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18=" ],]]] as [String : Any] - TrustKit.initialize(withConfiguration:trustKitConfig) + TrustKit.initSharedInstance(withConfiguration:trustKitConfig) ``` After TrustKit has been initialized, a diff --git a/TrustKit/TrustKit.h b/TrustKit/TrustKit.h index 1c1e25cb..a43a0384 100644 --- a/TrustKit/TrustKit.h +++ b/TrustKit/TrustKit.h @@ -30,15 +30,14 @@ NS_ASSUME_NONNULL_BEGIN configured for the App. In singleton mode, the policy can be set either: * By adding it to the App's _Info.plist_ under the `TSKConfiguration` key, or - * By programmatically supplying it using the `+initializeWithConfiguration:` method. + * By programmatically supplying it using the `+initSharedInstanceWithConfiguration:` method. In singleton mode, TrustKit can only be initialized once so only one of the two techniques should be used. For more complex Apps where multiple SSL pinning policies need to be used independently (for example within different frameworks), TrustKit can be used in "multi-instance" mode - by leveraging the `-initWithConfiguration:identifier:` method described at the end of this - page. + by leveraging the `-initWithConfiguration:` method described at the end of this page. A TrustKit pinning policy is a dictionary which contains some global, App-wide settings (of type `TSKGlobalConfigurationKey`) as well as domain-specific configuration keys @@ -64,8 +63,8 @@ NS_ASSUME_NONNULL_BEGIN ``` When setting the pinning policy programmatically, it has to be supplied to the - `initializeWithConfiguration:` method as a dictionary in order to initialize TrustKit. - For example: + `initSharedInstanceWithConfiguration:` method as a dictionary in order to initialize + TrustKit. For example: ``` NSDictionary *trustKitConfig = @@ -91,7 +90,7 @@ NS_ASSUME_NONNULL_BEGIN } }}; - [TrustKit initializeWithConfiguration:trustKitConfig]; + [TrustKit initSharedInstanceWithConfiguration:trustKitConfig]; trustKit = [TrustKit sharedInstance]; ``` @@ -109,7 +108,7 @@ NS_ASSUME_NONNULL_BEGIN "WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18=" ],]]] as [String : Any] - TrustKit.initialize(withConfiguration:trustKitConfig) + TrustKit.initSharedInstance(withConfiguration:trustKitConfig) ``` After initialization, the `TrustKit` instance's `pinningValidator` should be used to implement @@ -128,11 +127,11 @@ NS_ASSUME_NONNULL_BEGIN already been initialized. */ -+ (void)initializeWithConfiguration:(NSDictionary *)trustKitConfig; ++ (void)initSharedInstanceWithConfiguration:(NSDictionary *)trustKitConfig; /** - Retrieve the global TrustKit singleton instance. Raises an exception if `+initializeWithConfiguration:` + Retrieve the global TrustKit singleton instance. Raises an exception if `+initSharedInstanceWithConfiguration:` has not yet been invoked. @return the shared TrustKit singleton diff --git a/TrustKit/TrustKit.m b/TrustKit/TrustKit.m index 202bf548..8ca7a6ce 100644 --- a/TrustKit/TrustKit.m +++ b/TrustKit/TrustKit.m @@ -81,14 +81,14 @@ + (instancetype)sharedInstance if (!sharedTrustKit) { // TrustKit should only be initialized once so we don't double swizzle or get into anything unexpected [NSException raise:@"TrustKit was not initialized" - format:@"TrustKit must be initialized using +initializeWithConfiguration: prior to accessing sharedInstance"]; + format:@"TrustKit must be initialized using +initSharedInstanceWithConfiguration: prior to accessing sharedInstance"]; } return sharedTrustKit; } -+ (void)initializeWithConfiguration:(NSDictionary *)trustKitConfig ++ (void)initSharedInstanceWithConfiguration:(NSDictionary *)trustKitConfig { - TSKLog(@"Configuration passed via explicit call to initializeWithConfiguration:"); + TSKLog(@"Configuration passed via explicit call to initSharedInstanceWithConfiguration:"); static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ @@ -266,6 +266,6 @@ + (void)setLoggerBlock:(void (^)(NSString *))block if (trustKitConfigFromInfoPlist) { TSKLog(@"Configuration supplied via the App's Info.plist"); - [TrustKit initializeWithConfiguration:trustKitConfigFromInfoPlist]; + [TrustKit initSharedInstanceWithConfiguration:trustKitConfigFromInfoPlist]; } } diff --git a/TrustKitDemo/TrustKitDemo/AppDelegate.m b/TrustKitDemo/TrustKitDemo/AppDelegate.m index f1be1170..344038ba 100644 --- a/TrustKitDemo/TrustKitDemo/AppDelegate.m +++ b/TrustKitDemo/TrustKitDemo/AppDelegate.m @@ -69,7 +69,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( ] }}}; - [TrustKit initializeWithConfiguration:trustKitConfig]; + [TrustKit initSharedInstanceWithConfiguration:trustKitConfig]; // Demonstrate how to receive pin validation notifications (only useful for performance/metrics) [TrustKit sharedInstance].pinningValidatorCallbackQueue =dispatch_get_main_queue(); diff --git a/TrustKitDemo/TrustKitDemoInSwift/AppDelegate.swift b/TrustKitDemo/TrustKitDemoInSwift/AppDelegate.swift index f755fb59..791246c3 100644 --- a/TrustKitDemo/TrustKitDemoInSwift/AppDelegate.swift +++ b/TrustKitDemo/TrustKitDemoInSwift/AppDelegate.swift @@ -50,7 +50,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ] ]] as [String : Any] - TrustKit.initialize(withConfiguration: trustKitConfig) + TrustKit.initSharedInstance(withConfiguration: trustKitConfig) return true } diff --git a/docs/getting-started.md b/docs/getting-started.md index b0d8f14c..9c684434 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -77,7 +77,7 @@ folder on disk. ### Configuring a Pinning Policy Enabling TrustKit within an App requires generating a pinning policy and then -initializing TrustKit by calling the `initializeWithConfiguration:` method with your +initializing TrustKit by calling the `initSharedInstanceWithConfiguration:` method with your pinning policy. A pinning policy is a dictionary of domain names and pinning configuration keys.