uerceg
uerceg

Reputation: 4807

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?

Upvotes: 42

Views: 43527

Answers (3)

Nithin Khan SS
Nithin Khan SS

Reputation: 71

  • Open Xcode and select your project.
  • Go to the "Project Navigator" and select the root project node.
  • Select the "General" tab at the top of the project editor.
  • Scroll down to the "Linked Frameworks and Libraries" section.
  • Look for the library you want to check for updates (e.g. BoringSSL) and find the version number listed next to it.
  • Search for the latest version of that library online, either on the library's official website or on a package manager such as CocoaPods or Carthage.
  • Compare the version number you found in Xcode with the latest version available online.
  • If there is a newer version available, follow the steps provided by the library or package manager to update to the latest version.

Upvotes: 0

storoj
storoj

Reputation: 1867

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

Upvotes: 49

joshbillions
joshbillions

Reputation: 1069

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

Upvotes: 6

Related Questions