@@ -48,6 +48,9 @@ - (instancetype)init
48
48
if (self)
49
49
{
50
50
enableDebug = NO ;
51
+
52
+ // Tchap: initialize Tchap domain flag.
53
+ self.ImOnATchapGouvFrPage = NO ;
51
54
}
52
55
return self;
53
56
}
@@ -58,6 +61,9 @@ - (id)initWithURL:(NSString*)URL
58
61
if (self)
59
62
{
60
63
_URL = URL;
64
+
65
+ // Tchap: initialize Tchap domain flag.
66
+ self.ImOnATchapGouvFrPage = [self urlBelongsToTchapGouvFrDomain: [NSURL URLWithString: URL]];
61
67
}
62
68
return self;
63
69
}
@@ -267,6 +273,15 @@ - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAut
267
273
268
274
// Check first whether there are some pinned certificates (certificate included in the bundle).
269
275
NSArray *paths = [[NSBundle mainBundle ] pathsForResourcesOfType: @" cer" inDirectory: @" ." ];
276
+
277
+ // Tchap: if current request doesn't belong to Tchap domain, ignore Certificate Pinning system.
278
+ // It is to avoid activating Certificate Pinning (using Certigna Root Certificate) on ProConnect (agentconnect.gouv.fr) page
279
+ // that is using Let's Encrypt certificate actually.
280
+ // This case happens when launching UIA on a ProConnect SSO logged user.
281
+ if (!self.ImOnATchapGouvFrPage ) {
282
+ paths = @[];
283
+ }
284
+
270
285
if (paths.count )
271
286
{
272
287
NSMutableArray *pinnedCertificates = [NSMutableArray array ];
@@ -324,6 +339,15 @@ - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAut
324
339
}
325
340
}
326
341
342
+ // Tchap: public method to help subclasses know if current request belongs to Tchap domain.
343
+ - (BOOL )urlBelongsToTchapGouvFrDomain : (NSURL *)url
344
+ {
345
+ // Tchap: Tchap domain substring.
346
+ static NSString *const kTchapMXKWebViewViewControllerTchapGouvFrHostnamePart = @" .tchap.gouv.fr" ;
347
+
348
+ return [url.host containsString: kTchapMXKWebViewViewControllerTchapGouvFrHostnamePart ];
349
+ }
350
+
327
351
#pragma mark - WKUIDelegate
328
352
329
353
- (WKWebView *)webView : (WKWebView *)webView createWebViewWithConfiguration : (nonnull WKWebViewConfiguration *)configuration forNavigationAction : (nonnull WKNavigationAction *)navigationAction windowFeatures : (nonnull WKWindowFeatures *)windowFeatures
0 commit comments