Skip to content

Commit 0c1e234

Browse files
committed
feat: 🎉 ssl pinning [CS-36095]
1 parent 9dbbda1 commit 0c1e234

File tree

14 files changed

+145
-34
lines changed

14 files changed

+145
-34
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### Version: 3.11.0
2+
#### Date: Apr-04-2023
3+
4+
##### Enahancement:
5+
- SSL pinning for CSURLSession using CSURLSessionDelegate
6+
17
### Version: 3.10.1
28
#### Date: Nov-11-2022
39

Contentstack.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Contentstack'
3-
s.version = '3.10.1'
3+
s.version = '3.11.0'
44
s.summary = 'Contentstack is a headless CMS with an API-first approach that puts content at the centre.'
55

66
s.description = <<-DESC
@@ -12,7 +12,7 @@ s.homepage = 'https://www.contentstack.com/'
1212
s.license = { :type => 'Commercial',:text => 'See https://www.contentstack.com/'}
1313
s.author = { 'Contentstack' => 'support@contentstack.io' }
1414

15-
s.source = { :git => 'https://github.com/contentstack/contentstack-ios.git', :tag => 'v3.10.1' }
15+
s.source = { :git => 'https://github.com/contentstack/contentstack-ios.git', :tag => 'v3.11.0' }
1616
s.social_media_url = 'https://twitter.com/Contentstack'
1717

1818
s.ios.deployment_target = '8.0'

Contentstack.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
0F9C0FC6221ADAC90091205A /* SyncStack.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F9C0FAD221ADAC90091205A /* SyncStack.h */; settings = {ATTRIBUTES = (Public, ); }; };
4949
0F9C0FC7221ADAC90091205A /* Entry.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F9C0FAE221ADAC90091205A /* Entry.h */; settings = {ATTRIBUTES = (Public, ); }; };
5050
0F9C0FC8221ADAC90091205A /* NamespacedDependencies.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F9C0FB0221ADAC90091205A /* NamespacedDependencies.h */; };
51+
0FD6BAEF29CD6E73001A0930 /* CSURLSessionDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD6BAEE29CD6E73001A0930 /* CSURLSessionDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
5152
0FEAEF282361A18600985FF9 /* CSNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FEAEF232361A18600985FF9 /* CSNetworking.h */; };
5253
0FEAEF292361A18600985FF9 /* CSError.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FEAEF242361A18600985FF9 /* CSError.h */; settings = {ATTRIBUTES = (Public, ); }; };
5354
0FEAEF2A2361A18600985FF9 /* CSURLSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0FEAEF252361A18600985FF9 /* CSURLSessionManager.m */; };
@@ -166,6 +167,7 @@
166167
0F9C0FAD221ADAC90091205A /* SyncStack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SyncStack.h; sourceTree = "<group>"; };
167168
0F9C0FAE221ADAC90091205A /* Entry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Entry.h; sourceTree = "<group>"; };
168169
0F9C0FB0221ADAC90091205A /* NamespacedDependencies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NamespacedDependencies.h; sourceTree = "<group>"; };
170+
0FD6BAEE29CD6E73001A0930 /* CSURLSessionDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSURLSessionDelegate.h; sourceTree = "<group>"; };
169171
0FDC02D1254A9CFA005EDDE3 /* libContentstackUtils.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libContentstackUtils.a; sourceTree = BUILT_PRODUCTS_DIR; };
170172
0FEAEF232361A18600985FF9 /* CSNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSNetworking.h; sourceTree = "<group>"; };
171173
0FEAEF242361A18600985FF9 /* CSError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSError.h; sourceTree = "<group>"; };
@@ -307,6 +309,7 @@
307309
0F9C0FA7221ADAC80091205A /* Stack.m */,
308310
0F9C0FAD221ADAC90091205A /* SyncStack.h */,
309311
0F9C0FA0221ADAC80091205A /* SyncStack.m */,
312+
0FD6BAEE29CD6E73001A0930 /* CSURLSessionDelegate.h */,
310313
0F9C0FAF221ADAC90091205A /* ThirdPartyNamespaceHeader */,
311314
230B38C41C16E98B00444A14 /* Info.plist */,
312315
);
@@ -507,6 +510,7 @@
507510
230B39011C16EB8D00444A14 /* ISO8601DateFormatter.h in Headers */,
508511
23A53F401E276C83001DBE35 /* CSIOInternalHeaders.h in Headers */,
509512
0F9C0FB1221ADAC90091205A /* AssetLibrary.h in Headers */,
513+
0FD6BAEF29CD6E73001A0930 /* CSURLSessionDelegate.h in Headers */,
510514
0F9C0FB6221ADAC90091205A /* Config.h in Headers */,
511515
0F9C0FC2221ADAC90091205A /* Query.h in Headers */,
512516
0FEAEF292361A18600985FF9 /* CSError.h in Headers */,
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// CSURLSessionDelegate.h
3+
// Contentstack
4+
//
5+
// Created by Uttam Ukkoji on 24/03/23.
6+
// Copyright © 2023 Contentstack. All rights reserved.
7+
//
8+
9+
#ifndef CSURLSessionDelegate_h
10+
#define CSURLSessionDelegate_h
11+
#import <Foundation/NSURLRequest.h>
12+
13+
@class NSURLSession;
14+
@class NSURLAuthenticationChallenge;
15+
16+
API_AVAILABLE(macos(10.9), ios(7.0), watchos(2.0), tvos(9.0))
17+
@protocol CSURLSessionDelegate <NSObject>
18+
@optional
19+
20+
- (void)URLSession:(NSURLSession *_Nonnull)session didReceiveChallenge:(NSURLAuthenticationChallenge *_Nonnull)challenge
21+
completionHandler:(void (NS_SWIFT_SENDABLE ^_Nonnull)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * _Nullable credential))completionHandler;
22+
23+
- (void)URLSession:(NSURLSession *_Nonnull)session task:(NSURLSessionTask *_Nonnull)task
24+
didReceiveChallenge:(NSURLAuthenticationChallenge *_Nonnull)challenge
25+
completionHandler:(void (NS_SWIFT_SENDABLE ^_Nonnull)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * _Nullable credential))completionHandler;
26+
27+
@end
28+
#endif /* CSURLSessionDelegate_h */

Contentstack/Config.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#import <Foundation/Foundation.h>
1010
#import "ContentstackDefinitions.h"
11+
#import "CSURLSessionDelegate.h"
1112
@interface Config : NSObject
1213

1314
/**----------------------------------------------------------------------------------------
@@ -72,4 +73,19 @@
7273
*/
7374
@property (nonatomic, copy) NSString *branch;
7475

76+
77+
/**
78+
Branch id for the
79+
80+
//Obj-C
81+
Config *config = [[Config alloc] init];
82+
config.delegate = [[CSDelegate alloc] init];
83+
84+
//Swift
85+
var config:Config = Config()
86+
config.delegate = CSDelegate()
87+
88+
*/
89+
@property (nullable, retain) id<CSURLSessionDelegate> delegate;
90+
7591
@end

Contentstack/Contentstack.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#import <Contentstack/QueryResult.h>
2020
#import <Contentstack/Group.h>
2121
#import <Contentstack/SyncStack.h>
22+
#import <Contentstack/CSURLSessionDelegate.h>
2223

2324
@class Stack;
2425

Contentstack/ContentstackDefinitions.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878
typedef NS_ENUM(NSUInteger, ContentstackRegion){
7979
US = 0,
8080
EU,
81-
AZURE_NA
81+
AZURE_NA,
82+
AZURE_EU
8283
};
8384

8485
typedef NS_ENUM(NSUInteger, Language) {

Contentstack/Stack.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ - (instancetype)initWithAPIKey:(NSString*)apiKey andaccessToken:(NSString *)acce
3939
_apiKey = apiKey;
4040
_accessToken = accessToken;
4141

42-
_network = [[CSIOCoreHTTPNetworking alloc] init];
42+
_network = [[CSIOCoreHTTPNetworking alloc] initWithDelegate:_config.delegate];
4343
_stackHeaders = [NSMutableDictionary dictionary];
4444
ISO8601DateFormatter *formatter = [[ISO8601DateFormatter alloc]init];
4545
_commonDateFormatter = formatter;

ContentstackInternal/CSIOCoreHTTPNetworking.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
//
88

99
#import <Foundation/Foundation.h>
10+
#import <Contentstack/CSURLSessionDelegate.h>
1011
#import "CSIOCoreNetworkingProtocol.h"
1112

12-
@interface CSIOCoreHTTPNetworking : NSObject <CSIOCoreNetworkingProtocol>
1313

14+
@interface CSIOCoreHTTPNetworking : NSObject <CSIOCoreNetworkingProtocol>
15+
-(instancetype)initWithDelegate: (id<CSURLSessionDelegate>) delegate;
1416
@end

ContentstackInternal/CSIOCoreHTTPNetworking.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ - (NSString *)URLEncodedStringValue {
140140
}
141141
@implementation CSIOCoreHTTPNetworking
142142

143-
-(instancetype)init {
143+
-(instancetype)initWithDelegate: (id<CSURLSessionDelegate>) delegate {
144144
if (self=[super init]) {
145145
// _httpSessionManager = [AFHTTPSessionManager manager];
146-
_urlSessionManager = [CSURLSessionManager manager:[self configuration]];
146+
_urlSessionManager = [CSURLSessionManager manager:[self configuration] delegate:delegate];
147147
[NSURLCache setSharedURLCache:[CSIOURLCache standardURLCache]];
148148
// [self sessionManagerQueryStringSerialization];
149149
}

0 commit comments

Comments
 (0)