Nativescript-https plugin issue



I have to enable ssl pining in my app. So, I had to use plugin. I have follow the implementation steps correctly. But when I make the https request, iOS app crash in AFNetworking EXC_BAD_Access error

Android app gives this error

JS: nativescript-https > Disabled SSL pinning by default
JS: nativescript-https > enableSSLPinning error ReferenceError: okhttp3 is not defined
JS: Https.request error ReferenceError: okhttp3 is not defined

Certs folder


/// <reference path="./node_modules/tns-core-modules/tns-core-modules.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />


import { File, Folder, knownFolders, path } from 'file-system'
import * as Https from 'nativescript-https'

in the constructor

let dir = knownFolders.currentApp().getFolder('certs')
let certificate = dir.getFile('').path
Https.enableSSLPinning({ host: '', certificate: certificate});


            url: '',
            method: 'GET',
            headers: {
                'content-type': 'application/json'
        }).then(function(response) {
            console.log('Https.request response', response)
        }).catch(function(error) {
            console.error('Https.request error', error)

Please help me to identify whats is the issue here.

tns version 4.0.1 node v6.11.5


Looks like the support libraries are not installed properly, try a clean build on Android.

For iOS, did you do the steps here.


@manojdcoder thanks for reply.
For iOS, I have set NSAllowsArbitraryLoads to true
Android, I have clean built. But still the same issue


@manojdcoder I have remove https plugin and add again. Also remove both platforms and add again.
After that, android is working now.
But ios still has same issue.
I have added two NSLogs to AFHTTPSSessionManager class.


Securitypolicy AFSSLPinningModePublicKey
baseURL scheme (null)

It seems something wrong with setting the certificate and host in the angular code. By right, Securitypolicy should be AFSSLPinningModeCertificate and baseURL schme should have https.

Any idea?