Skip to content

Commit f687e84

Browse files
Merge pull request #1189 from tchapgouv/1188-probleme-avec-le-certificat-tls-de-proconnect
Permettre l'identification par ProConnect pour les UIA
2 parents b918488 + 22e7a24 commit f687e84

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

Riot/Modules/Home/Fallback/AuthFallBackViewController.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati
143143
{
144144
NSString *urlString = navigationAction.request.URL.absoluteString;
145145

146+
// Tchap: set flag meaning the webview is handling a Tchap domain request.
147+
self.ImOnATchapGouvFrPage = [self urlBelongsToTchapGouvFrDomain:navigationAction.request.URL];
148+
146149
// TODO: We should use the WebKit PostMessage API and the
147150
// `didReceiveScriptMessage` delegate to manage the JS<->Native bridge
148151
if ([urlString hasPrefix:@"js:"])

Riot/Modules/MatrixKit/Controllers/MXKWebViewViewController.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,10 @@ Please see LICENSE in the repository root for full details.
6060
// Tchap: give access to backButton to allow a 'Cancel' functionnality.
6161
- (void)setBackButton:(UIBarButtonItem *)button;
6262

63+
// Tchap: flag to get and set if the current loading request belong to Tchap domain.
64+
@property (nonatomic) BOOL ImOnATchapGouvFrPage;
65+
66+
// Tchap: method to call to know if a request url belongs to Tchap domain.
67+
- (BOOL)urlBelongsToTchapGouvFrDomain:(NSURL *)url;
68+
6369
@end

Riot/Modules/MatrixKit/Controllers/MXKWebViewViewController.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ - (instancetype)init
4848
if (self)
4949
{
5050
enableDebug = NO;
51+
52+
// Tchap: initialize Tchap domain flag.
53+
self.ImOnATchapGouvFrPage = NO;
5154
}
5255
return self;
5356
}
@@ -58,6 +61,9 @@ - (id)initWithURL:(NSString*)URL
5861
if (self)
5962
{
6063
_URL = URL;
64+
65+
// Tchap: initialize Tchap domain flag.
66+
self.ImOnATchapGouvFrPage = [self urlBelongsToTchapGouvFrDomain:[NSURL URLWithString:URL]];
6167
}
6268
return self;
6369
}
@@ -267,6 +273,15 @@ - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAut
267273

268274
// Check first whether there are some pinned certificates (certificate included in the bundle).
269275
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+
270285
if (paths.count)
271286
{
272287
NSMutableArray *pinnedCertificates = [NSMutableArray array];
@@ -324,6 +339,15 @@ - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAut
324339
}
325340
}
326341

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+
327351
#pragma mark - WKUIDelegate
328352

329353
- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(nonnull WKWebViewConfiguration *)configuration forNavigationAction:(nonnull WKNavigationAction *)navigationAction windowFeatures:(nonnull WKWindowFeatures *)windowFeatures

changelog.d/1188.change

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Permettre l'identification par ProConnect pour les opérations sécurisées par une ré-authentification (comme la régénération du Code de Récupération)

0 commit comments

Comments
 (0)