Skip to content

Commit 8f4d276

Browse files
committed
Fix websocket tests, fix cert pinning, update okhttp
1 parent bc252a2 commit 8f4d276

File tree

7 files changed

+19
-54
lines changed

7 files changed

+19
-54
lines changed

demo-angular/src/app/home/home.component.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616
<Button col="2" text="Clear pins" (tap)="clearPins()"></Button>
1717
</GridLayout>
1818

19-
<GridLayout row="0" rowSpan="2" rows="auto" columns="*, *, *" *ngIf="websocket && !isLoading">
19+
<GridLayout row="0" rowSpan="2" rows="auto" columns="*, *" *ngIf="websocket && !isLoading">
2020
<Button col="0" text="Send text" (tap)="sendMessage()"></Button>
21-
<Button col="1" text="Send binary" (tap)="sendBinary()"></Button>
22-
<Button col="2" text="Disconnect" (tap)="disconnectWebsocket()"></Button>
21+
<Button col="1" text="Disconnect" (tap)="disconnectWebsocket()"></Button>
2322
</GridLayout>
2423

2524
<GridLayout row="2" rows="*" columns="*" style="border-width: 1; border-color: #e0e0e0; margin: 10; padding: 10;">

demo-angular/src/app/home/home.component.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export class HomeComponent implements OnInit, OnDestroy {
120120
this.isLoading = true;
121121

122122
newWebsocketConnection({
123-
url: "wss://echo.websocket.org",
123+
url: "wss://ws.postman-echo.com/raw",
124124
method: "GET",
125125
}, {
126126
// It's important to wrap callbacks in ngzone when you do anything binding related.
@@ -182,17 +182,6 @@ export class HomeComponent implements OnInit, OnDestroy {
182182
});
183183
}
184184

185-
sendBinary() {
186-
if (this.websocket) {
187-
const blob = new Blob(["binaryFileContent"], {
188-
type: "image/png",
189-
});
190-
191-
// @ts-ignore
192-
this.websocket.sendBinary(Blob.InternalAccessor.getBuffer(blob).buffer.slice(0) as ArrayBuffer);
193-
}
194-
}
195-
196185
disconnectWebsocket() {
197186
if (this.websocket) {
198187
this.websocket.close(1000, "Goodbye");
@@ -213,9 +202,9 @@ export class HomeComponent implements OnInit, OnDestroy {
213202

214203
pinGood() {
215204
certificatePinningClear();
216-
certificatePinningAdd("*.placeholder.com", ["CDCU5TkA8n3L8+QM7dyTjfRlxWibigF+1cxMzRhlJV4=", "YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg=", "Vjs8r4z+80wjNcr1YKepWQboSIRi63WsWXhIMN+eWys="]);
217-
certificatePinningAdd("**.github.com", ["ORH27mxcLwxnNpR7e0i6pdDPWLXdpeWgr5bEfFVbxW8=", "k2v657xBsOVe1PQRwOsHsw3bsGT2VzIqz5K+59sNQws=", "WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="]);
218-
certificatePinningAdd("loripsum.net", ["7ReOzYJ7YC1mMc2CWTuaMDuzynt8xZ+HDQ6K8o+4okk=", "YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg=", "Vjs8r4z+80wjNcr1YKepWQboSIRi63WsWXhIMN+eWys="]);
205+
certificatePinningAdd("*.placeholder.com", ["DlYSp/cLxpoA6dBq3hszKK/r0p7Q/pnSRVQnAdQNf/o=", "FEzVOUp4dF3gI0ZVPRJhFbSJVXR+uQmMH65xhs1glH4=", "Y9mvm0exBk1JoQ57f9Vm28jKo5lFm/woKcVxrYxu80o="]);
206+
certificatePinningAdd("**.github.com", ["uyPYgclc5Jt69vKu92vci6etcBDY8UNTyrHQZJpVoZY=", "e0IRz5Tio3GA1Xs4fUVWmH1xHDiH2dMbVtCBSkOIdqM=", "r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E="]);
207+
certificatePinningAdd("loripsum.net", ["9lgc3b7Et90OtTYg2rJRAl18RhhQIuI/z9NCj27wSpc=", "jQJTbIh0grw0/1TkHSumWb+Fs0Ggogr621gT3PvPKG0=", "C5+lpZ7tcVwmwQIMcRtPbsQtWLABXhQzejna0wHFr8M="]);
219208

220209
this.contentType = "text";
221210
this.contentText = "Good certificates pinned, try to do a request";

demo-vue/app/components/Home.vue

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818
<Button col="2" text="Clear pins" @tap="clearPins"></Button>
1919
</GridLayout>
2020

21-
<GridLayout row="0" rowSpan="2" rows="auto" columns="*, *, *" v-show="websocket && !isLoading">
21+
<GridLayout row="0" rowSpan="2" rows="auto" columns="*, *" v-show="websocket && !isLoading">
2222
<Button col="0" text="Send text" @tap="sendMessage"></Button>
23-
<Button col="1" text="Send binary" @tap="sendBinary"></Button>
24-
<Button col="2" text="Disconnect" @tap="disconnectWebsocket"></Button>
23+
<Button col="1" text="Disconnect" @tap="disconnectWebsocket"></Button>
2524
</GridLayout>
2625

2726
<GridLayout row="2" rows="*" columns="*" style="border-width: 1; border-color: #e0e0e0; margin: 10; padding: 10;">
@@ -140,7 +139,7 @@ export default {
140139
this.isLoading = true;
141140
142141
newWebsocketConnection({
143-
url: "wss://echo.websocket.org",
142+
url: "wss://ws.postman-echo.com/raw",
144143
method: "GET",
145144
}, {
146145
onClosed: (code, reason) => {
@@ -186,16 +185,6 @@ export default {
186185
}
187186
});
188187
},
189-
sendBinary() {
190-
if (this.websocket) {
191-
const blob = new Blob(["binaryFileContent"], {
192-
type: "image/png",
193-
});
194-
195-
// @ts-ignore
196-
this.websocket.sendBinary(Blob.InternalAccessor.getBuffer(blob).buffer.slice(0));
197-
}
198-
},
199188
disconnectWebsocket() {
200189
if (this.websocket) {
201190
this.websocket.close(1000, "Goodbye");
@@ -214,9 +203,9 @@ export default {
214203
},
215204
pinGood() {
216205
certificatePinningClear();
217-
certificatePinningAdd("*.placeholder.com", ["CDCU5TkA8n3L8+QM7dyTjfRlxWibigF+1cxMzRhlJV4=", "YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg=", "Vjs8r4z+80wjNcr1YKepWQboSIRi63WsWXhIMN+eWys="]);
218-
certificatePinningAdd("**.github.com", ["ORH27mxcLwxnNpR7e0i6pdDPWLXdpeWgr5bEfFVbxW8=", "k2v657xBsOVe1PQRwOsHsw3bsGT2VzIqz5K+59sNQws=", "WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="]);
219-
certificatePinningAdd("loripsum.net", ["7ReOzYJ7YC1mMc2CWTuaMDuzynt8xZ+HDQ6K8o+4okk=", "YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg=", "Vjs8r4z+80wjNcr1YKepWQboSIRi63WsWXhIMN+eWys="]);
206+
certificatePinningAdd("*.placeholder.com", ["DlYSp/cLxpoA6dBq3hszKK/r0p7Q/pnSRVQnAdQNf/o=", "FEzVOUp4dF3gI0ZVPRJhFbSJVXR+uQmMH65xhs1glH4=", "Y9mvm0exBk1JoQ57f9Vm28jKo5lFm/woKcVxrYxu80o="]);
207+
certificatePinningAdd("**.github.com", ["uyPYgclc5Jt69vKu92vci6etcBDY8UNTyrHQZJpVoZY=", "e0IRz5Tio3GA1Xs4fUVWmH1xHDiH2dMbVtCBSkOIdqM=", "r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E="]);
208+
certificatePinningAdd("loripsum.net", ["9lgc3b7Et90OtTYg2rJRAl18RhhQIuI/z9NCj27wSpc=", "jQJTbIh0grw0/1TkHSumWb+Fs0Ggogr621gT3PvPKG0=", "C5+lpZ7tcVwmwQIMcRtPbsQtWLABXhQzejna0wHFr8M="]);
220209
221210
this.contentType = "text";
222211
this.contentText = "Good certificates pinned, try to do a request";

demo/app/home/home-page.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121
<Button col="2" text="Clear pins" tap="{{ clearPins }}"/>
2222
</GridLayout>
2323

24-
<GridLayout row="0" rowSpan="2" rows="auto" columns="*, *, *" visibility="{{ hasWebSocket && !isLoading ? 'visible' : 'collapse' }}">
24+
<GridLayout row="0" rowSpan="2" rows="auto" columns="*, *" visibility="{{ hasWebSocket && !isLoading ? 'visible' : 'collapse' }}">
2525
<Button col="0" text="Send text" tap="{{ sendMessage }}"/>
26-
<Button col="1" text="Send binary" tap="{{ sendBinary }}"/>
27-
<Button col="2" text="Disconnect" tap="{{ disconnectWebsocket }}"/>
26+
<Button col="1" text="Disconnect" tap="{{ disconnectWebsocket }}"/>
2827
</GridLayout>
2928

3029
<GridLayout row="2" rows="*" columns="*" style="border-width: 1; border-color: #e0e0e0; margin: 10; padding: 10;">

demo/app/home/home-view-model.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export class HomeViewModel extends Observable {
9797
this.set("isLoading", true);
9898

9999
newWebsocketConnection({
100-
url: "wss://echo.websocket.org",
100+
url: "wss://ws.postman-echo.com/raw",
101101
method: "GET",
102102
}, {
103103
// It's important to wrap callbacks in ngzone when you do anything binding related.
@@ -150,17 +150,6 @@ export class HomeViewModel extends Observable {
150150
});
151151
}
152152

153-
sendBinary() {
154-
if (this.websocket) {
155-
const blob = new Blob(["binaryFileContent"], {
156-
type: "image/png",
157-
});
158-
159-
// @ts-ignore
160-
this.websocket.sendBinary(Blob.InternalAccessor.getBuffer(blob).buffer.slice(0) as ArrayBuffer);
161-
}
162-
}
163-
164153
disconnectWebsocket() {
165154
if (this.websocket) {
166155
this.websocket.close(1000, "Goodbye");
@@ -181,9 +170,9 @@ export class HomeViewModel extends Observable {
181170

182171
pinGood() {
183172
certificatePinningClear();
184-
certificatePinningAdd("*.placeholder.com", ["CDCU5TkA8n3L8+QM7dyTjfRlxWibigF+1cxMzRhlJV4=", "YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg=", "Vjs8r4z+80wjNcr1YKepWQboSIRi63WsWXhIMN+eWys="]);
185-
certificatePinningAdd("**.github.com", ["ORH27mxcLwxnNpR7e0i6pdDPWLXdpeWgr5bEfFVbxW8=", "k2v657xBsOVe1PQRwOsHsw3bsGT2VzIqz5K+59sNQws=", "WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="]);
186-
certificatePinningAdd("loripsum.net", ["7ReOzYJ7YC1mMc2CWTuaMDuzynt8xZ+HDQ6K8o+4okk=", "YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg=", "Vjs8r4z+80wjNcr1YKepWQboSIRi63WsWXhIMN+eWys="]);
173+
certificatePinningAdd("*.placeholder.com", ["DlYSp/cLxpoA6dBq3hszKK/r0p7Q/pnSRVQnAdQNf/o=", "FEzVOUp4dF3gI0ZVPRJhFbSJVXR+uQmMH65xhs1glH4=", "Y9mvm0exBk1JoQ57f9Vm28jKo5lFm/woKcVxrYxu80o="]);
174+
certificatePinningAdd("**.github.com", ["uyPYgclc5Jt69vKu92vci6etcBDY8UNTyrHQZJpVoZY=", "e0IRz5Tio3GA1Xs4fUVWmH1xHDiH2dMbVtCBSkOIdqM=", "r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E="]);
175+
certificatePinningAdd("loripsum.net", ["9lgc3b7Et90OtTYg2rJRAl18RhhQIuI/z9NCj27wSpc=", "jQJTbIh0grw0/1TkHSumWb+Fs0Ggogr621gT3PvPKG0=", "C5+lpZ7tcVwmwQIMcRtPbsQtWLABXhQzejna0wHFr8M="]);
187176

188177
this.contentType = "text";
189178
this.contentText = "Good certificates pinned, try to do a request";

src/platforms/android/include.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ android {
55
}
66

77
dependencies {
8-
implementation "com.squareup.okhttp3:okhttp:4.4.+"
8+
implementation "com.squareup.okhttp3:okhttp:4.10.+"
99
}
-11.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)