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

[FIX] Unwanted clear keychain and request challenges #4826

Merged
merged 5 commits into from
Jan 18, 2023
Merged
Changes from 1 commit
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
Next Next commit
Patches fixing completions
diegolmello committed Jan 17, 2023

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit a783bec1f1b31b8ea04f1aa1c67a6dc10c9b4bcb
54 changes: 54 additions & 0 deletions patches/react-native+0.68.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
diff --git a/node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.mm b/node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.mm
index 8667fb9..676867d 100644
--- a/node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.mm
+++ b/node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.mm
@@ -140,12 +140,12 @@ -(void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticati

// https://github.com/ammarahm-ed/react-native-mmkv-storage/blob/master/src/loader.js#L31
NSString *key = [secureStorage getSecureKey:[self stringToHex:@"com.MMKV.default"]];
+ NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];

if (key == NULL) {
- return;
+ return completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, credential);
}

- NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
NSData *cryptKey = [key dataUsingEncoding:NSUTF8StringEncoding];
MMKV *mmkv = [MMKV mmkvWithID:@"default" cryptKey:cryptKey mode:MMKVMultiProcess];
clientSSL = [mmkv getStringForKey:host];
diff --git a/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m b/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m
index b60b519..fbaae31 100644
--- a/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m
+++ b/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m
@@ -557,19 +557,17 @@ - (void)_initializeStreams
// https://github.com/ammarahm-ed/react-native-mmkv-storage/blob/master/src/loader.js#L31
NSString *key = [secureStorage getSecureKey:[self stringToHex:@"com.MMKV.default"]];

- if (key == NULL) {
- return;
- }
-
- NSData *cryptKey = [key dataUsingEncoding:NSUTF8StringEncoding];
- MMKV *mmkv = [MMKV mmkvWithID:@"default" cryptKey:cryptKey mode:MMKVMultiProcess];
- clientSSL = [mmkv getStringForKey:host];
- if (clientSSL) {
- NSData *data = [clientSSL dataUsingEncoding:NSUTF8StringEncoding];
- id dict = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
- NSString *path = [dict objectForKey:@"path"];
- NSString *password = [dict objectForKey:@"password"];
- [self setClientSSL:path password:password options:SSLOptions];
+ if (key != NULL) {
+ NSData *cryptKey = [key dataUsingEncoding:NSUTF8StringEncoding];
+ MMKV *mmkv = [MMKV mmkvWithID:@"default" cryptKey:cryptKey mode:MMKVMultiProcess];
+ clientSSL = [mmkv getStringForKey:host];
+ if (clientSSL) {
+ NSData *data = [clientSSL dataUsingEncoding:NSUTF8StringEncoding];
+ id dict = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
+ NSString *path = [dict objectForKey:@"path"];
+ NSString *password = [dict objectForKey:@"password"];
+ [self setClientSSL:path password:password options:SSLOptions];
+ }
}

[_outputStream setProperty:SSLOptions
4 changes: 2 additions & 2 deletions patches/react-native-webview+10.3.2.patch
Original file line number Diff line number Diff line change
@@ -197,16 +197,16 @@ index 02b4238..e0635ed 100644
+
+ // https://github.com/ammarahm-ed/react-native-mmkv-storage/blob/master/src/loader.js#L31
+ NSString *key = [secureStorage getSecureKey:[self stringToHex:@"com.MMKV.default"]];
+ NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
+
+ if (key == NULL) {
+ return;
+ return completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, credential);
+ }
+
+ NSData *cryptKey = [key dataUsingEncoding:NSUTF8StringEncoding];
+ MMKV *mmkv = [MMKV mmkvWithID:@"default" cryptKey:cryptKey mode:MMKVMultiProcess];
+ clientSSL = [mmkv getObjectOfClass:[NSDictionary class] forKey:host];
+
+ NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
+
+ if (clientSSL != (id)[NSNull null]) {
+ NSString *path = [clientSSL objectForKey:@"path"];
6 changes: 3 additions & 3 deletions patches/rn-fetch-blob+0.12.0.patch
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ index 602d51d..920d975 100644
public String getName() {
return "RNFetchBlob";
diff --git a/node_modules/rn-fetch-blob/ios/RNFetchBlobRequest.m b/node_modules/rn-fetch-blob/ios/RNFetchBlobRequest.m
index cdbe6b1..c0ce9bd 100644
index cdbe6b1..04e5e7b 100644
--- a/node_modules/rn-fetch-blob/ios/RNFetchBlobRequest.m
+++ b/node_modules/rn-fetch-blob/ios/RNFetchBlobRequest.m
@@ -15,6 +15,9 @@
@@ -118,12 +118,12 @@ index cdbe6b1..c0ce9bd 100644
+
+ // https://github.com/ammarahm-ed/react-native-mmkv-storage/blob/master/src/loader.js#L31
+ NSString *key = [secureStorage getSecureKey:[self stringToHex:@"com.MMKV.default"]];
+ NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
+
+ if (key == NULL) {
+ return;
+ return completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, credential);
+ }
+
+ NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
+ NSData *cryptKey = [key dataUsingEncoding:NSUTF8StringEncoding];
+ MMKV *mmkv = [MMKV mmkvWithID:@"default" cryptKey:cryptKey mode:MMKVMultiProcess];
+ clientSSL = [mmkv getStringForKey:host];