-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathreact-native-webview+13.16.1.patch
More file actions
197 lines (189 loc) · 9.45 KB
/
Copy pathreact-native-webview+13.16.1.patch
File metadata and controls
197 lines (189 loc) · 9.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
diff --git a/node_modules/react-native-webview/android/.project b/node_modules/react-native-webview/android/.project
new file mode 100644
index 0000000..122755b
--- /dev/null
+++ b/node_modules/react-native-webview/android/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>react-native-webview</name>
+ <comment>Project react-native-webview created by Buildship.</comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
+ </natures>
+ <filteredResources>
+ <filter>
+ <id>1760118463063</id>
+ <name></name>
+ <type>30</type>
+ <matcher>
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
+ <arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
+ </matcher>
+ </filter>
+ </filteredResources>
+</projectDescription>
diff --git a/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java b/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java
index 80c6803..97df1fa 100644
--- a/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java
+++ b/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java
@@ -219,6 +219,7 @@ public class RNCWebView extends WebView implements LifecycleEventListener {
public void setWebViewClient(WebViewClient client) {
super.setWebViewClient(client);
if (client instanceof RNCWebViewClient) {
+ ((RNCWebViewClient) client).setReactContext(this.getReactApplicationContext());
mRNCWebViewClient = (RNCWebViewClient) client;
mRNCWebViewClient.setProgressChangedFilter(progressChangedFilter);
}
diff --git a/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewClient.java b/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewClient.java
index 0287e1c..65174cc 100644
--- a/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewClient.java
+++ b/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewClient.java
@@ -35,6 +35,11 @@ import com.reactnativecommunity.webview.events.TopShouldStartLoadWithRequestEven
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
+import java.security.cert.X509Certificate;
+import java.security.PrivateKey;
+import android.webkit.ClientCertRequest;
+import android.os.AsyncTask;
+import android.security.KeyChain;
import java.util.concurrent.atomic.AtomicReference;
public class RNCWebViewClient extends WebViewClient {
@@ -45,10 +50,60 @@ public class RNCWebViewClient extends WebViewClient {
protected RNCWebView.ProgressChangedFilter progressChangedFilter = null;
protected @Nullable RNCBasicAuthCredential basicAuthCredential = null;
+ private static String certificateAlias = null;
+ private ReactContext reactContext;
+
public void setBasicAuthCredential(@Nullable RNCBasicAuthCredential credential) {
basicAuthCredential = credential;
}
+ public static void setCertificateAlias(String alias) {
+ certificateAlias = alias;
+ }
+
+ public void setReactContext(ReactContext reactContext) {
+ this.reactContext = reactContext;
+ }
+
+ @Override
+ public void onReceivedClientCertRequest(WebView view, ClientCertRequest request) {
+ class SslStuff {
+ PrivateKey privKey;
+ X509Certificate[] certChain;
+
+ public SslStuff(PrivateKey privKey, X509Certificate[] certChain) {
+ this.privKey = privKey;
+ this.certChain = certChain;
+ }
+ }
+
+ if (certificateAlias != null && reactContext != null) {
+ AsyncTask<Void, Void, SslStuff> task = new AsyncTask<Void, Void, SslStuff>() {
+ @Override
+ protected SslStuff doInBackground(Void... params) {
+ try {
+ PrivateKey privKey = KeyChain.getPrivateKey(reactContext, certificateAlias);
+ X509Certificate[] certChain = KeyChain.getCertificateChain(reactContext, certificateAlias);
+
+ return new SslStuff(privKey, certChain);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ @Override
+ protected void onPostExecute(SslStuff sslStuff) {
+ if (sslStuff != null) {
+ request.proceed(sslStuff.privKey, sslStuff.certChain);
+ }
+ }
+ };
+ task.execute();
+ } else {
+ super.onReceivedClientCertRequest(view, request);
+ }
+ }
+
@Override
public void onPageFinished(WebView webView, String url) {
super.onPageFinished(webView, url);
diff --git a/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModuleImpl.java b/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModuleImpl.java
index 951749c..05792b8 100644
--- a/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModuleImpl.java
+++ b/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModuleImpl.java
@@ -551,4 +551,8 @@ public class RNCWebViewModuleImpl implements ActivityEventListener {
}
return (PermissionAwareActivity) activity;
}
+
+ public static void setCertificateAlias(String alias) {
+ RNCWebViewClient.setCertificateAlias(alias);
+ }
}
\ No newline at end of file
diff --git a/node_modules/react-native-webview/android/src/newarch/com/reactnativecommunity/webview/RNCWebViewManager.java b/node_modules/react-native-webview/android/src/newarch/com/reactnativecommunity/webview/RNCWebViewManager.java
index 4709e28..0144ef9 100644
--- a/node_modules/react-native-webview/android/src/newarch/com/reactnativecommunity/webview/RNCWebViewManager.java
+++ b/node_modules/react-native-webview/android/src/newarch/com/reactnativecommunity/webview/RNCWebViewManager.java
@@ -45,6 +45,10 @@ public class RNCWebViewManager extends ViewGroupManager<RNCWebViewWrapper>
mRNCWebViewManagerImpl = new RNCWebViewManagerImpl(true);
}
+ public static void setCertificateAlias(String alias) {
+ RNCWebViewModule.setCertificateAlias(alias);
+ }
+
@Nullable
@Override
protected ViewManagerDelegate<RNCWebViewWrapper> getDelegate() {
diff --git a/node_modules/react-native-webview/android/src/newarch/com/reactnativecommunity/webview/RNCWebViewModule.java b/node_modules/react-native-webview/android/src/newarch/com/reactnativecommunity/webview/RNCWebViewModule.java
index 4df0aae..867aa73 100644
--- a/node_modules/react-native-webview/android/src/newarch/com/reactnativecommunity/webview/RNCWebViewModule.java
+++ b/node_modules/react-native-webview/android/src/newarch/com/reactnativecommunity/webview/RNCWebViewModule.java
@@ -49,6 +49,10 @@ public class RNCWebViewModule extends NativeRNCWebViewModuleSpec {
return mRNCWebViewModuleImpl.grantFileDownloaderPermissions(downloadingMessage, lackPermissionToDownloadMessage);
}
+ public static void setCertificateAlias(String alias) {
+ RNCWebViewModuleImpl.setCertificateAlias(alias);
+ }
+
@NonNull
@Override
public String getName() {
diff --git a/node_modules/react-native-webview/android/src/oldarch/com/reactnativecommunity/webview/RNCWebViewManager.java b/node_modules/react-native-webview/android/src/oldarch/com/reactnativecommunity/webview/RNCWebViewManager.java
index 974337f..0099677 100644
--- a/node_modules/react-native-webview/android/src/oldarch/com/reactnativecommunity/webview/RNCWebViewManager.java
+++ b/node_modules/react-native-webview/android/src/oldarch/com/reactnativecommunity/webview/RNCWebViewManager.java
@@ -32,6 +32,10 @@ public class RNCWebViewManager extends ViewGroupManager<RNCWebViewWrapper> {
mRNCWebViewManagerImpl = new RNCWebViewManagerImpl();
}
+ public static void setCertificateAlias(String alias) {
+ RNCWebViewModule.setCertificateAlias(alias);
+ }
+
@Override
public String getName() {
return RNCWebViewManagerImpl.NAME;
diff --git a/node_modules/react-native-webview/android/src/oldarch/com/reactnativecommunity/webview/RNCWebViewModule.java b/node_modules/react-native-webview/android/src/oldarch/com/reactnativecommunity/webview/RNCWebViewModule.java
index 526cc16..8f3318d 100644
--- a/node_modules/react-native-webview/android/src/oldarch/com/reactnativecommunity/webview/RNCWebViewModule.java
+++ b/node_modules/react-native-webview/android/src/oldarch/com/reactnativecommunity/webview/RNCWebViewModule.java
@@ -51,6 +51,10 @@ public class RNCWebViewModule extends ReactContextBaseJavaModule {
return mRNCWebViewModuleImpl.grantFileDownloaderPermissions(downloadingMessage, lackPermissionToDownloadMessage);
}
+ public static void setCertificateAlias(String alias) {
+ RNCWebViewModuleImpl.setCertificateAlias(alias);
+ }
+
@NonNull
@Override
public String getName() {