Skip to content

Commit 99faa4f

Browse files
Updated demo: show usage of valid & invalid cert
1 parent f018d5f commit 99faa4f

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

demo/app/assets/httpbin.org.cer

14 Bytes
Binary file not shown.
1.35 KB
Binary file not shown.

demo/app/main-page.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ export function enableSSLPinning(args: Observable.EventData) {
6161
context.set('enabled', true);
6262
}
6363

64+
export function enableSSLPinningExpired(args: Observable.EventData) {
65+
let dir = fs.knownFolders.currentApp().getFolder('assets');
66+
let certificate = dir.getFile('httpbin.org.expired.cer').path;
67+
Https.enableSSLPinning({host: 'httpbin.org', certificate});
68+
let context = (args.object as Page.View).bindingContext as Observable.Observable;
69+
context.set('enabled', true);
70+
}
71+
6472
export function disableSSLPinning(args: Observable.EventData) {
6573
Https.disableSSLPinning();
6674
let context = (args.object as Page.View).bindingContext as Observable.Observable;

demo/app/main-page.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
<Button text="GET Httpbin" tap="getHttpbin" class="t-20 btn btn-primary btn-active"/>
1010
<Button text="GET Httpbin (large response)" tap="getHttpbinLargeResponse" class="t-20 btn btn-primary btn-active"/>
1111
<Button text="POST Httpbin " tap="postHttpbin" class="t-20 btn btn-primary btn-active"/>
12-
<Button text="Enable Httpbin SSL Pinning" tap="enableSSLPinning" class="t-20 btn btn-primary btn-active"/>
13-
<Button text="Disable SSL Pinning" tap="disableSSLPinning" class="t-20 btn btn-primary btn-active"/>
12+
<Button text="Httpbin Pinning ON" tap="enableSSLPinning" class="t-20 btn btn-primary btn-active"/>
13+
<Button text="Httpbin Pinning ON, expired cert" tap="enableSSLPinningExpired" class="t-20 btn btn-primary btn-active"/>
14+
<Button text="Httpbin Pinning OFF" tap="disableSSLPinning" class="t-20 btn btn-primary btn-active"/>
1415
<Label text="Here's a spinner to show the main thread is not blocked by network IO" textWrap="true" class="m-20"/>
1516
<ActivityIndicator busy="true"/>
1617
</StackLayout>

0 commit comments

Comments
 (0)