Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to register for BoringSSL log debug updates

When debugging app in Xcode 9 beta while it's running on iPhone with iOS 11 beta installed, I started to notice following messages when performing networking calls:

[] network_config_register_boringssl_log_debug_updates Failed to register for BoringSSL log debug updates
[BoringSSL] Function boringssl_context_get_peer_npn_data: line 1212 Peer's advertised NPN data is NULL or empty

Any idea what is causing this?

like image 789
uerceg Avatar asked Jun 07 '17 10:06

uerceg


2 Answers

Open the Xcode Scheme editor and add a new environment variable OS_ACTIVITY_MODE and set to disable.

NOTE: Beware, this will disable ALL NSLog outputs, not just the BoringSSL messages.

enter image description here

like image 192
joshbillions Avatar answered Nov 13 '22 07:11

joshbillions


UPDATE

There's actually a very convenient way to silence certain logs for a specific simulator:

xcrun simctl spawn booted log config --subsystem com.apple.network --category boringssl --mode level:off

It is also recommended to silence other common non-important logs as well:

xcrun simctl spawn booted log config --subsystem com.apple.CoreBluetooth --mode level:off
xcrun simctl spawn booted log config --subsystem com.apple.CoreTelephony --mode level:off

Original answer (background)

These annoying messages come from libboringssl.dylib :: boringssl_metrics_log_event:

int boringssl_metrics_log_event(...) {
  ...
  if (g_boringssl_log != nil && os_log_type_enabled(g_boringssl_log, OS_LOG_TYPE_ERROR) {
    os_log_error(g_boringssl_log, "%s(%d) Failed to log metrics", "boringssl_metrics_log_metric_block_invoke", 151);
  }
  ...
}

An easy way to silence these messages is to nullify g_boringssl_log.

g_boringssl_log is a global variable:

os_log_t g_boringssl_log = nil;

It gets initialized in boringssl_log_open:

void boringssl_log_open() {
   static dispatch_token onceToken = nil;
   dispatch_once(onceToken, ^{
     g_boringssl_log = os_log_create("com.apple.network", "boringssl");
   });
}

IMO the easiest solution to nullify g_boring_ssl is to skip the execution of dispatch_once.

That could be achieved with setting a breakpoint to __boringssl_log_open_block_invoke with action thread return. This breakpoint will be called once thanks to dispatch_once, but the function's body will not be executed because of immediate thread return. So g_boringssl_log will never be initialized, and there will be no logs in the Console.

PS I might also recommend setting a similar breakpoint for ____nwlog_connection_log_block_invoke from libnetwork.dylib.

An example of breakpoint

like image 42
storoj Avatar answered Nov 13 '22 09:11

storoj