You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+35-4Lines changed: 35 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,6 +43,7 @@ npm run demo.android
43
43
We also recommend adding `"skipLibCheck": true,` to your `tsconfig.json`.
44
44
More information on that can be found [here](https://github.com/NativeScript/NativeScript/tree/master/tns-platform-declarations).
45
45
46
+
Install the plugin:
46
47
```bash
47
48
tns plugin add nativescript-https
48
49
```
@@ -66,7 +67,7 @@ Https.request({
66
67
console.error('Https.request error', error)
67
68
})
68
69
```
69
-
### Hitting an API using `POST` method with body
70
+
### Hitting an API using `POST` method with JSON body
70
71
```typescript
71
72
import*asHttpsfrom'nativescript-https'
72
73
Https.request({
@@ -89,13 +90,43 @@ Https.request({
89
90
})
90
91
```
91
92
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.
92
96
97
+

93
98
99
+
#### Enabling SSL pinning
100
+
```typescript
101
+
import { knownFolders } from'file-system'
102
+
import*asHttpsfrom'nativescript-https'
103
+
let dir =knownFolders.currentApp().getFolder('certs')
104
+
let certificate =dir.getFile('wegossipapp.com.cer').path
Once you've enabled SSL pinning you **CAN NOT** re-enable with a different `host` or `certificate` file.
94
108
109
+
#### Disabling SSL pinning
110
+
```typescript
111
+
import*asHttpsfrom'nativescript-https'
112
+
Https.disableSSLPinning()
113
+
```
95
114
96
-
97
-
98
-
115
+
#### Pinning Options
116
+
```typescript
117
+
exportinterfaceHttpsSSLPinningOptions {
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.
0 commit comments