Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SSL Pinning #839

Merged
merged 3 commits into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Analytics/Classes/Internal/SEGHTTPClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, strong) SEGRequestFactory requestFactory;
@property (nonatomic, readonly) NSMutableDictionary<NSString *, NSURLSession *> *sessionsByWriteKey;
@property (nonatomic, readonly) NSURLSession *genericSession;
@property (nonatomic, weak) id<NSURLSessionDelegate> httpSessionDelegate;

+ (SEGRequestFactory)defaultRequestFactory;
+ (NSString *)authorizationHeader:(NSString *)writeKey;
Expand Down
2 changes: 1 addition & 1 deletion Analytics/Classes/Internal/SEGHTTPClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ - (NSURLSession *)sessionForWriteKey:(NSString *)writeKey
@"Authorization" : [@"Basic " stringByAppendingString:[[self class] authorizationHeader:writeKey]],
@"User-Agent" : [NSString stringWithFormat:@"analytics-ios/%@", [SEGAnalytics version]],
};
session = [NSURLSession sessionWithConfiguration:config];
session = [NSURLSession sessionWithConfiguration:config delegate:self.httpSessionDelegate delegateQueue:NULL];
self.sessionsByWriteKey[writeKey] = session;
}
return session;
Expand Down
1 change: 1 addition & 0 deletions Analytics/Classes/Internal/SEGSegmentIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ - (id)initWithAnalytics:(SEGAnalytics *)analytics httpClient:(SEGHTTPClient *)ht
self.analytics = analytics;
self.configuration = analytics.configuration;
self.httpClient = httpClient;
self.httpClient.httpSessionDelegate = analytics.configuration.httpSessionDelegate;
self.storage = storage;
self.apiURL = [SEGMENT_API_BASE URLByAppendingPathComponent:@"import"];
self.userId = [self getUserId];
Expand Down
5 changes: 5 additions & 0 deletions Analytics/Classes/SEGAnalyticsConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,9 @@ typedef NSMutableURLRequest *_Nonnull (^SEGRequestFactory)(NSURL *_Nonnull);
*/
@property (nonatomic, strong, nonnull) NSDictionary<NSString*, NSString*>* payloadFilters;

/**
* An optional delegate that handles NSURLSessionDelegate callbacks
*/
@property (nonatomic, strong, nullable) id<NSURLSessionDelegate> httpSessionDelegate;

@end
1 change: 1 addition & 0 deletions AnalyticsTests/AnalyticsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class AnalyticsTests: QuickSpec {
expect(analytics.configuration.shouldUseLocationServices) == false
expect(analytics.configuration.enableAdvertisingTracking) == true
expect(analytics.configuration.shouldUseBluetooth) == false
expect(analytics.configuration.httpSessionDelegate) == nil
expect(analytics.getAnonymousId()).toNot(beNil())
}

Expand Down