Skip to content

Commit 46ec50c

Browse files
authored
Update README.md
1 parent cc5d722 commit 46ec50c

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

README.md

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ npm run demo.android
4343
We also recommend adding `"skipLibCheck": true,` to your `tsconfig.json`.
4444
More information on that can be found [here](https://github.com/NativeScript/NativeScript/tree/master/tns-platform-declarations).
4545

46+
Install the plugin:
4647
```bash
4748
tns plugin add nativescript-https
4849
```
@@ -66,7 +67,7 @@ Https.request({
6667
console.error('Https.request error', error)
6768
})
6869
```
69-
### Hitting an API using `POST` method with body
70+
### Hitting an API using `POST` method with JSON body
7071
```typescript
7172
import * as Https from 'nativescript-https'
7273
Https.request({
@@ -89,13 +90,43 @@ Https.request({
8990
})
9091
```
9192

93+
## Configuration
94+
### Installing your SSL certificate
95+
Create a folder called `certs` in your projects `app` folder like so `project_root/app/certs`. Using chrome, go to the URL where the SSL certificate resides. View the details then drag and drop the certificate image into the `certs` folder.
9296

97+
![Installing your SSL certificate](http://i.imgur.com/hn4duT3.gif)
9398

99+
#### Enabling SSL pinning
100+
```typescript
101+
import { knownFolders } from 'file-system'
102+
import * as Https from 'nativescript-https'
103+
let dir = knownFolders.currentApp().getFolder('certs')
104+
let certificate = dir.getFile('wegossipapp.com.cer').path
105+
Https.enableSSLPinning({ host: 'wegossipapp.com', certificate })
106+
```
107+
Once you've enabled SSL pinning you **CAN NOT** re-enable with a different `host` or `certificate` file.
94108

109+
#### Disabling SSL pinning
110+
```typescript
111+
import * as Https from 'nativescript-https'
112+
Https.disableSSLPinning()
113+
```
95114

96-
97-
98-
115+
#### Pinning Options
116+
```typescript
117+
export interface HttpsSSLPinningOptions {
118+
host: string
119+
certificate: string
120+
allowInvalidCertificates?: boolean
121+
validatesDomainName?: boolean
122+
}
123+
```
124+
Option | Description
125+
------------ | -------------
126+
`host: string` | This must be the top level domain name eg `wegossipapp.com` or `www.wegossipapp.com`.
127+
`certificate: string` | The uri path to your `.cer` certificate file.
128+
`allowInvalidCertificates?: boolean` | Default: `false`. This should **always** be `false` if you are using SSL pinning. Set this to `true` if you're using a self-signed certificate.
129+
`validatesDomainName?: boolean` | Default: `true`. Determines if the domain name should be validated with your pinned certificate.
99130

100131

101132

0 commit comments

Comments
 (0)