From 8db1dbef7198ffe526e747c696ac2aca0dbb6952 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 21 Aug 2018 20:39:21 +0200 Subject: [PATCH] feat(http): add setSSLCertMode function --- src/@ionic-native/plugins/http/index.ts | 33 ++++++++++--------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/src/@ionic-native/plugins/http/index.ts b/src/@ionic-native/plugins/http/index.ts index 3407f22f8..1f2a32f6a 100644 --- a/src/@ionic-native/plugins/http/index.ts +++ b/src/@ionic-native/plugins/http/index.ts @@ -154,7 +154,9 @@ export class HTTP extends IonicNativePlugin { * @param url {string} */ @Cordova({ sync: true }) - getCookieString(url: string): string { return; } + getCookieString(url: string): string { + return; + } /** * Get global request timeout value in seconds. @@ -173,26 +175,15 @@ export class HTTP extends IonicNativePlugin { setRequestTimeout(timeout: number): void {} /** - * Enable or disable SSL Pinning. This defaults to false. - * - * To use SSL pinning you must include at least one .cer SSL certificate in your app project. You can pin to your server certificate or to one of the issuing CA certificates. For ios include your certificate in the root level of your bundle (just add the .cer file to your project/target at the root level). For android include your certificate in your project's platforms/android/assets folder. In both cases all .cer files found will be loaded automatically. If you only have a .pem certificate see this [stackoverflow answer](https://stackoverflow.com/questions/16583428/how-to-convert-an-ssl-certificate-in-linux/16583429#16583429). You want to convert it to a DER encoded certificate with a .cer extension. - * - * As an alternative, you can store your .cer files in the www/certificates folder. - * @param enable {boolean} Set to true to enable - * @returns {Promise} returns a promise that will resolve on success, and reject on failure + * Set SSL Cert handling mode, being one of the following values + * default: default SSL cert handling using system's CA certs + * nocheck: disable SSL cert checking, trusting all certs (meant to be used only for testing purposes) + * pinned: trust only provided certs + * @see https://github.com/silkimen/cordova-plugin-advanced-http#setsslcertmode + * @param {'default' | 'nocheck' | 'pinned'} mode SSL Cert handling mode */ @Cordova() - enableSSLPinning(enable: boolean): Promise { - return; - } - - /** - * Accept all SSL certificates. Or disabled accepting all certificates. Defaults to false. - * @param accept {boolean} Set to true to accept - * @returns {Promise} returns a promise that will resolve on success, and reject on failure - */ - @Cordova() - acceptAllCerts(accept: boolean): Promise { + setSSLCertMode(mode: 'default' | 'nocheck' | 'pinned'): Promise { return; } @@ -202,7 +193,9 @@ export class HTTP extends IonicNativePlugin { * @returns {Promise} returns a promise that will resolve on success, and reject on failure */ @Cordova() - disableRedirect(disable: boolean): Promise { return; } + disableRedirect(disable: boolean): Promise { + return; + } /** * Make a POST request