@@ -90,6 +90,7 @@ function patchTargetLib(targetLib) {
90
90
) ;
91
91
92
92
const SSL_VERIFY_OK = 0x0 ;
93
+ const SSL_VERIFY_INVALID = 0x1 ;
93
94
94
95
// We cache the verification callbacks we create. In general (in testing, 100% of the time) the
95
96
// 'real' callback is always the exact same address, so this is much more efficient than creating
@@ -98,13 +99,15 @@ function patchTargetLib(targetLib) {
98
99
99
100
const buildVerificationCallback = ( realCallbackAddr ) => {
100
101
if ( ! verificationCallbackCache [ realCallbackAddr ] ) {
101
- const realCallback = new NativeFunction ( realCallbackAddr , 'int' , [ 'pointer' , 'pointer' ] ) ;
102
+ const realCallback = realCallbackAddr
103
+ ? new NativeFunction ( realCallbackAddr , 'int' , [ 'pointer' , 'pointer' ] )
104
+ : ( ) => SSL_VERIFY_INVALID ; // Callback can be null - treat as invalid (=our validation only)
102
105
103
106
const hookedCallback = new NativeCallback ( function ( ssl , out_alert ) {
104
107
let realResult = false ;
105
108
106
109
if ( targetLib !== 'libboringssl.dylib' ) {
107
- // Cronet assumes its callback is always calls , and crashes if not. iOS's BoringSSL
110
+ // Cronet assumes its callback is always called , and crashes if not. iOS's BoringSSL
108
111
// meanwhile seems to use some negative checks in its callback, and rejects the
109
112
// connection independently of the return value here if it's called with a bad cert.
110
113
// End result: we *only sometimes* proactively call the callback.
0 commit comments