diff --git a/README.md b/README.md index e34ce62..e46c330 100644 --- a/README.md +++ b/README.md @@ -483,6 +483,20 @@ certificatePinningAdd("mydomain.com", ["DCU5TkA8n3L8+QM7dyTjfRlxWibigF+1cxMzRhlJ certificatePinningClear(); ``` +### Allow SSL errors and self-signed certificates + +You can allow SSL errors and self-signed certificates if you want. This only works on android devices. + +```typescript +import { allowSslErrors } from "@klippa/nativescript-http"; + +/** + * Allow SSL errors and self-signed certificates + * @param allow true/false + */ +allowSslErrors(true); +``` + ## Roadmap * Cache control * Allowing self signed certificates (WIP in feature/self-signed) diff --git a/src/index.d.ts b/src/index.d.ts index 2cd5d26..66654ee 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -114,6 +114,7 @@ export declare function clearCookies(): void; /** * Allow SSL errors and self-signed certificates + * ** Only Android ** * @param allow true/false */ export declare function allowSslErrors(allow: boolean): void; diff --git a/src/package.json b/src/package.json index edeccee..e80acd4 100644 --- a/src/package.json +++ b/src/package.json @@ -1,75 +1,75 @@ { - "name": "@klippa/nativescript-http", - "version": "3.0.5", - "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", - "main": "http", - "typings": "index.d.ts", - "nativescript": { - "platforms": { - "android": "6.5.0", - "ios": "6.5.0" - } - }, - "repository": { - "type": "git", - "url": "https://github.com/klippa-app/nativescript-http.git" - }, - "scripts": { - "tsc": "npm i && ts-patch install && tsc", - "build": "npm i && ts-patch install && npm run ngcc && npm run ngc", - "build.old": "npm i && ts-patch install && npm run ngcc && npm run ngc", - "tslint": "cd .. && tslint \"**/*.ts\" --config tslint.json --exclude \"**/node_modules/**\" --exclude \"**/typings/**\"", - "ci.tslint": "npm i && ts-patch install && tslint '**/*.ts' --config '../tslint.json' --exclude '**/node_modules/**' --exclude '**/platforms/**' --exclude '**/typings/**'", - "demo.ios": "npm i && ts-patch install && cd ../demo && ns run ios", - "demo.android": "npm i && ts-patch install && cd ../demo && ns run android", - "demo.reset": "cd ../demo && npx rimraf -- hooks node_modules platforms package-lock.json", - "demo-angular.ios": "npm i && ts-patch install && cd ../demo-angular && ns run ios", - "demo-angular.android": "npm i && ts-patch install && cd ../demo-angular && ns run android", - "demo-angular.reset": "cd ../demo-angular && npx rimraf -- hooks node_modules platforms package-lock.json", - "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", - "clean": "npm run demo.reset && npm run demo-angular.reset && npx rimraf -- node_modules package-lock.json && npm i", - "ngcc": "node --max-old-space-size=8192 ./node_modules/.bin/ngcc -p es2015", - "ngc": "node --max-old-space-size=8192 ./node_modules/.bin/ngc" - }, - "keywords": [ - "NativeScript", - "JavaScript", - "Android", - "iOS" - ], - "author": { - "name": "Jeroen Bobbeldijk", - "email": "jeroen@klippa.com" - }, - "bugs": { - "url": "https://github.com/klippa-app/nativescript-http/issues" - }, - "license": "MIT", - "homepage": "https://github.com/klippa-app/nativescript-http", - "devDependencies": { - "@angular/common": "~14.0.0", - "@angular/compiler": "~14.0.0", - "@angular/compiler-cli": "~14.0.0", - "@angular/core": "~14.0.0", - "@nativescript/angular": "~14.0.0", - "@nativescript/core": "~8.2.0", - "@nativescript/types": "~8.2.0", - "@nativescript/webpack": "~5.0.6", - "@angular/router": "~14.0.0", - "@angular/animations": "~14.0.0", - "@angular/forms": "~14.0.0", - "@angular/platform-browser": "~14.0.0", - "prompt": "^1.0.0", - "rimraf": "^2.6.3", - "rxjs": "~7.5.0", - "semver": "^5.6.0", - "ts-patch": "^1.3.0", - "tslint": "6.1.3", - "typescript": "~4.7.0", - "zone.js": "~0.11.5" - }, - "dependencies": { - "ts-node": "9.1.1" - }, - "bootstrapper": "nativescript-plugin-seed" + "name": "@klippa/nativescript-http", + "version": "3.0.5", + "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", + "main": "http", + "typings": "index.d.ts", + "nativescript": { + "platforms": { + "android": "6.5.0", + "ios": "6.5.0" + } + }, + "repository": { + "type": "git", + "url": "https://github.com/klippa-app/nativescript-http.git" + }, + "scripts": { + "tsc": "npm i && ts-patch install && tsc", + "build": "npm i && ts-patch install && npm run ngcc && npm run ngc", + "build.old": "npm i && ts-patch install && npm run ngcc && npm run ngc", + "tslint": "cd .. && tslint \"**/*.ts\" --config tslint.json --exclude \"**/node_modules/**\" --exclude \"**/typings/**\"", + "ci.tslint": "npm i && ts-patch install && tslint '**/*.ts' --config '../tslint.json' --exclude '**/node_modules/**' --exclude '**/platforms/**' --exclude '**/typings/**'", + "demo.ios": "npm i && ts-patch install && cd ../demo && ns run ios", + "demo.android": "npm i && ts-patch install && cd ../demo && ns run android", + "demo.reset": "cd ../demo && npx rimraf -- hooks node_modules platforms package-lock.json", + "demo-angular.ios": "npm i && ts-patch install && cd ../demo-angular && ns run ios", + "demo-angular.android": "npm i && ts-patch install && cd ../demo-angular && ns run android", + "demo-angular.reset": "cd ../demo-angular && npx rimraf -- hooks node_modules platforms package-lock.json", + "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", + "clean": "npm run demo.reset && npm run demo-angular.reset && npx rimraf -- node_modules package-lock.json && npm i", + "ngcc": "node --max-old-space-size=8192 ./node_modules/.bin/ngcc -p es2015", + "ngc": "node --max-old-space-size=8192 ./node_modules/.bin/ngc" + }, + "keywords": [ + "NativeScript", + "JavaScript", + "Android", + "iOS" + ], + "author": { + "name": "Jeroen Bobbeldijk", + "email": "jeroen@klippa.com" + }, + "bugs": { + "url": "https://github.com/klippa-app/nativescript-http/issues" + }, + "license": "MIT", + "homepage": "https://github.com/klippa-app/nativescript-http", + "devDependencies": { + "@angular/common": "~14.0.0", + "@angular/compiler": "~14.0.0", + "@angular/compiler-cli": "~14.0.0", + "@angular/core": "~14.0.0", + "@nativescript/angular": "~14.0.0", + "@nativescript/core": "~8.2.0", + "@nativescript/types": "~8.2.0", + "@nativescript/webpack": "~5.0.6", + "@angular/router": "~14.0.0", + "@angular/animations": "~14.0.0", + "@angular/forms": "~14.0.0", + "@angular/platform-browser": "~14.0.0", + "prompt": "^1.0.0", + "rimraf": "^2.6.3", + "rxjs": "~7.5.0", + "semver": "^5.6.0", + "ts-patch": "^1.3.0", + "tslint": "6.1.3", + "typescript": "~4.7.0", + "zone.js": "~0.11.5" + }, + "dependencies": { + "ts-node": "9.1.1" + }, + "bootstrapper": "nativescript-plugin-seed" } diff --git a/src/platforms/android/java/com/klippa/NativeScriptHTTP/Async.java b/src/platforms/android/java/com/klippa/NativeScriptHTTP/Async.java index ddb2ca2..cad9b09 100644 --- a/src/platforms/android/java/com/klippa/NativeScriptHTTP/Async.java +++ b/src/platforms/android/java/com/klippa/NativeScriptHTTP/Async.java @@ -231,6 +231,7 @@ public static void ClearCookies() { } public static void AllowSslErrors(boolean allow) { + client = null; allowSslErrors = allow; InitClient(); }