Skip to content

Commit 481ccef

Browse files
author
Joonas Kannisto
committed
Reset client before setting allowSslErrors value
1 parent 05191a8 commit 481ccef

File tree

4 files changed

+89
-73
lines changed

4 files changed

+89
-73
lines changed

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,20 @@ certificatePinningAdd("mydomain.com", ["DCU5TkA8n3L8+QM7dyTjfRlxWibigF+1cxMzRhlJ
483483
certificatePinningClear();
484484
```
485485

486+
### Allow SSL errors and self-signed certificates
487+
488+
You can allow SSL errors and self-signed certificates if you want. This only works on android devices.
489+
490+
```typescript
491+
import { allowSslErrors } from "@klippa/nativescript-http";
492+
493+
/**
494+
* Allow SSL errors and self-signed certificates
495+
* @param allow true/false
496+
*/
497+
allowSslErrors(true);
498+
```
499+
486500
## Roadmap
487501
* Cache control
488502
* Allowing self signed certificates (WIP in feature/self-signed)

src/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ export declare function clearCookies(): void;
114114

115115
/**
116116
* Allow SSL errors and self-signed certificates
117+
* ** Only Android **
117118
* @param allow true/false
118119
*/
119120
export declare function allowSslErrors(allow: boolean): void;

src/package.json

+73-73
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,75 @@
11
{
2-
"name": "@klippa/nativescript-http",
3-
"version": "3.0.5",
4-
"description": "The best way to do HTTP requests in NativeScript, a drop-in replacement for the core HTTP with important improvements and additions like proper connection pooling, form data support and certificate pinning",
5-
"main": "http",
6-
"typings": "index.d.ts",
7-
"nativescript": {
8-
"platforms": {
9-
"android": "6.5.0",
10-
"ios": "6.5.0"
11-
}
12-
},
13-
"repository": {
14-
"type": "git",
15-
"url": "https://github.com/klippa-app/nativescript-http.git"
16-
},
17-
"scripts": {
18-
"tsc": "npm i && ts-patch install && tsc",
19-
"build": "npm i && ts-patch install && npm run ngcc && npm run ngc",
20-
"build.old": "npm i && ts-patch install && npm run ngcc && npm run ngc",
21-
"tslint": "cd .. && tslint \"**/*.ts\" --config tslint.json --exclude \"**/node_modules/**\" --exclude \"**/typings/**\"",
22-
"ci.tslint": "npm i && ts-patch install && tslint '**/*.ts' --config '../tslint.json' --exclude '**/node_modules/**' --exclude '**/platforms/**' --exclude '**/typings/**'",
23-
"demo.ios": "npm i && ts-patch install && cd ../demo && ns run ios",
24-
"demo.android": "npm i && ts-patch install && cd ../demo && ns run android",
25-
"demo.reset": "cd ../demo && npx rimraf -- hooks node_modules platforms package-lock.json",
26-
"demo-angular.ios": "npm i && ts-patch install && cd ../demo-angular && ns run ios",
27-
"demo-angular.android": "npm i && ts-patch install && cd ../demo-angular && ns run android",
28-
"demo-angular.reset": "cd ../demo-angular && npx rimraf -- hooks node_modules platforms package-lock.json",
29-
"plugin.prepare": "npm run build && cd ../demo && ns plugin remove @klippa/nativescript-http && ns plugin add ../src && cd ../demo-angular && ns plugin remove @klippa/nativescript-http && ns plugin add ../src",
30-
"clean": "npm run demo.reset && npm run demo-angular.reset && npx rimraf -- node_modules package-lock.json && npm i",
31-
"ngcc": "node --max-old-space-size=8192 ./node_modules/.bin/ngcc -p es2015",
32-
"ngc": "node --max-old-space-size=8192 ./node_modules/.bin/ngc"
33-
},
34-
"keywords": [
35-
"NativeScript",
36-
"JavaScript",
37-
"Android",
38-
"iOS"
39-
],
40-
"author": {
41-
"name": "Jeroen Bobbeldijk",
42-
"email": "[email protected]"
43-
},
44-
"bugs": {
45-
"url": "https://github.com/klippa-app/nativescript-http/issues"
46-
},
47-
"license": "MIT",
48-
"homepage": "https://github.com/klippa-app/nativescript-http",
49-
"devDependencies": {
50-
"@angular/common": "~14.0.0",
51-
"@angular/compiler": "~14.0.0",
52-
"@angular/compiler-cli": "~14.0.0",
53-
"@angular/core": "~14.0.0",
54-
"@nativescript/angular": "~14.0.0",
55-
"@nativescript/core": "~8.2.0",
56-
"@nativescript/types": "~8.2.0",
57-
"@nativescript/webpack": "~5.0.6",
58-
"@angular/router": "~14.0.0",
59-
"@angular/animations": "~14.0.0",
60-
"@angular/forms": "~14.0.0",
61-
"@angular/platform-browser": "~14.0.0",
62-
"prompt": "^1.0.0",
63-
"rimraf": "^2.6.3",
64-
"rxjs": "~7.5.0",
65-
"semver": "^5.6.0",
66-
"ts-patch": "^1.3.0",
67-
"tslint": "6.1.3",
68-
"typescript": "~4.7.0",
69-
"zone.js": "~0.11.5"
70-
},
71-
"dependencies": {
72-
"ts-node": "9.1.1"
73-
},
74-
"bootstrapper": "nativescript-plugin-seed"
2+
"name": "@klippa/nativescript-http",
3+
"version": "3.0.5",
4+
"description": "The best way to do HTTP requests in NativeScript, a drop-in replacement for the core HTTP with important improvements and additions like proper connection pooling, form data support and certificate pinning",
5+
"main": "http",
6+
"typings": "index.d.ts",
7+
"nativescript": {
8+
"platforms": {
9+
"android": "6.5.0",
10+
"ios": "6.5.0"
11+
}
12+
},
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/klippa-app/nativescript-http.git"
16+
},
17+
"scripts": {
18+
"tsc": "npm i && ts-patch install && tsc",
19+
"build": "npm i && ts-patch install && npm run ngcc && npm run ngc",
20+
"build.old": "npm i && ts-patch install && npm run ngcc && npm run ngc",
21+
"tslint": "cd .. && tslint \"**/*.ts\" --config tslint.json --exclude \"**/node_modules/**\" --exclude \"**/typings/**\"",
22+
"ci.tslint": "npm i && ts-patch install && tslint '**/*.ts' --config '../tslint.json' --exclude '**/node_modules/**' --exclude '**/platforms/**' --exclude '**/typings/**'",
23+
"demo.ios": "npm i && ts-patch install && cd ../demo && ns run ios",
24+
"demo.android": "npm i && ts-patch install && cd ../demo && ns run android",
25+
"demo.reset": "cd ../demo && npx rimraf -- hooks node_modules platforms package-lock.json",
26+
"demo-angular.ios": "npm i && ts-patch install && cd ../demo-angular && ns run ios",
27+
"demo-angular.android": "npm i && ts-patch install && cd ../demo-angular && ns run android",
28+
"demo-angular.reset": "cd ../demo-angular && npx rimraf -- hooks node_modules platforms package-lock.json",
29+
"plugin.prepare": "npm run build && cd ../demo && ns plugin remove @klippa/nativescript-http && ns plugin add ../src && cd ../demo-angular && ns plugin remove @klippa/nativescript-http && ns plugin add ../src",
30+
"clean": "npm run demo.reset && npm run demo-angular.reset && npx rimraf -- node_modules package-lock.json && npm i",
31+
"ngcc": "node --max-old-space-size=8192 ./node_modules/.bin/ngcc -p es2015",
32+
"ngc": "node --max-old-space-size=8192 ./node_modules/.bin/ngc"
33+
},
34+
"keywords": [
35+
"NativeScript",
36+
"JavaScript",
37+
"Android",
38+
"iOS"
39+
],
40+
"author": {
41+
"name": "Jeroen Bobbeldijk",
42+
"email": "[email protected]"
43+
},
44+
"bugs": {
45+
"url": "https://github.com/klippa-app/nativescript-http/issues"
46+
},
47+
"license": "MIT",
48+
"homepage": "https://github.com/klippa-app/nativescript-http",
49+
"devDependencies": {
50+
"@angular/common": "~14.0.0",
51+
"@angular/compiler": "~14.0.0",
52+
"@angular/compiler-cli": "~14.0.0",
53+
"@angular/core": "~14.0.0",
54+
"@nativescript/angular": "~14.0.0",
55+
"@nativescript/core": "~8.2.0",
56+
"@nativescript/types": "~8.2.0",
57+
"@nativescript/webpack": "~5.0.6",
58+
"@angular/router": "~14.0.0",
59+
"@angular/animations": "~14.0.0",
60+
"@angular/forms": "~14.0.0",
61+
"@angular/platform-browser": "~14.0.0",
62+
"prompt": "^1.0.0",
63+
"rimraf": "^2.6.3",
64+
"rxjs": "~7.5.0",
65+
"semver": "^5.6.0",
66+
"ts-patch": "^1.3.0",
67+
"tslint": "6.1.3",
68+
"typescript": "~4.7.0",
69+
"zone.js": "~0.11.5"
70+
},
71+
"dependencies": {
72+
"ts-node": "9.1.1"
73+
},
74+
"bootstrapper": "nativescript-plugin-seed"
7575
}

src/platforms/android/java/com/klippa/NativeScriptHTTP/Async.java

+1
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ public static void ClearCookies() {
231231
}
232232

233233
public static void AllowSslErrors(boolean allow) {
234+
client = null;
234235
allowSslErrors = allow;
235236
InitClient();
236237
}

0 commit comments

Comments
 (0)