cordova-plugin-advanced-http icon indicating copy to clipboard operation
cordova-plugin-advanced-http copied to clipboard

NSInvalidArgumentException on iOS when activating SSL-Pinning

Open NLueg opened this issue 4 years ago • 5 comments

Describe the bug Several iOS devices are crashing on start when SSL pinning is activated. Without it, we don't have any problem.

System info

  • affected HTTP plugin version: 3.0.1
  • affected platform(s) and version(s): iOS 14+, iOS 12.2
  • affected device(s): iPhone 11, iPhone X
  • cordova version: 9.0.0
  • cordova platform version(s): ios 6.1.1

Are you using ionic-native-wrapper?

Minimum viable code to reproduce

import {HTTP} from "@ionic-native/http/ngx";

constructor(
  private platform: Platform,
  private nativeHttp: HTTP,
) {
  this.initializePlugin();
}

private async initializePlugin() {
  this.platform.ready().then(() => this.nativeHttp.setServerTrustMode("pinned"))
}

Logs

We received the crash report you will see at the end of the issue. With a closer look into the device logs we found this exception:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString SSLPinningMode]: unrecognized selector sent to instance 0x282748c90'

Crash Report from iOS

Incident Identifier: 35074F1B-1267-465C-99BB-5A958F31B9A8
CrashReporter Key:   9a1d858ae0175759f7d96c231f9b63b378777483
Hardware Model:      iPhone12,1
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]


Date/Time:           2020-11-12 08:13:36.0958 +0100
Launch Time:         2020-11-12 08:13:33.3537 +0100
OS Version:          iPhone OS 14.2 (18B92)
Release Type:        User
Baseband Version:    2.02.04
Report Version:      104

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Subtype: KERN_PROTECTION_FAILURE at 0x0000003bd22bb580
VM Region Info: 0x3bd22bb580 is in 0x1000000000-0x7000000000;  bytes after start: 188209673600  bytes before end: 224107186815
      REGION TYPE                 START - END      [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      commpage (reserved)      fc0000000-1000000000 [  1.0G] ---/--- SM=NUL  ...(unallocated)
--->  GPU Carveout (reserved) 1000000000-7000000000 [384.0G] ---/--- SM=NUL  ...(unallocated)
      UNUSED SPACE AT END

Termination Signal: Bus error: 10
Termination Reason: Namespace SIGNAL, Code 0xa
Terminating Process: exc handler [1210]
Triggered by Thread:  14

...

Thread 14 name:  Dispatch queue: NSOperationQueue 0x12d235210 (QOS: UNSPECIFIED)
Thread 14 Crashed:
0   libobjc.A.dylib               	0x000000019c9fe0f8 objc_msgSend + 24
1   my app Test                 	0x000000010246ef90 0x102444000 + 176016
2   my app Test                 	0x000000010245f1d8 0x102444000 + 111064
3   my app Test                 	0x000000010248bfa4 0x102444000 + 294820
4   CFNetwork                     	0x0000000188c81a94 0x188aa8000 + 1940116
5   Foundation                    	0x00000001897f8850 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 24
6   Foundation                    	0x00000001896e5740 -[NSBlockOperation main] + 104
7   Foundation                    	0x00000001897faca4 __NSOPERATION_IS_INVOKING_MAIN__ + 24
8   Foundation                    	0x00000001896e53c8 -[NSOperation start] + 808
9   Foundation                    	0x00000001897fb74c __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 24
10  Foundation                    	0x00000001897fb1d4 __NSOQSchedule_f + 184
11  libdispatch.dylib             	0x00000001880aefb8 _dispatch_block_async_invoke2 + 148
12  libdispatch.dylib             	0x00000001880a0db0 _dispatch_client_callout + 20
13  libdispatch.dylib             	0x00000001880a412c _dispatch_continuation_pop + 416
14  libdispatch.dylib             	0x00000001880a3854 _dispatch_async_redirect_invoke + 592
15  libdispatch.dylib             	0x00000001880b193c _dispatch_root_queue_drain + 356
16  libdispatch.dylib             	0x00000001880b2120 _dispatch_worker_thread2 + 116
17  libsystem_pthread.dylib       	0x00000001d18c47c8 _pthread_wqthread + 216
18  libsystem_pthread.dylib       	0x00000001d18cb75c start_wqthread + 8

NLueg avatar Nov 18 '20 14:11 NLueg

@NLueg For IOS you will have to add DER certificate, refer image: Screenshot 2021-10-07 145355

shivakumarnr avatar Oct 07 '21 09:10 shivakumarnr

Ever after using DER base certificate still no luck :(

Screenshot 2021-11-05 at 2 21 31 PM

rsgone-aviso avatar Nov 05 '21 08:11 rsgone-aviso

@rsgone-aviso Once you add new .der certificate please rebuild the project. If after that the same issue persists your certificate as expired.

shivakumarnr avatar Nov 26 '21 09:11 shivakumarnr

@shivakumarnr It is very basic that after adding certificate/any-change, we will rebuild project for sure. BTW certificate is not expired as well. Thank you

rsgone-aviso avatar Nov 26 '21 09:11 rsgone-aviso