Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetworkInterface.GetAllNetworkInterfaces() returns an empty array on Mojave when notarized #20384

Open
rolfbjarne opened this issue Sep 14, 2020 · 3 comments
Assignees
Labels
area-Runtime: Interop os-macOS target-xamarin-mac if shared with iOS use target-xamarin-ios

Comments

@rolfbjarne
Copy link
Member

From @guygodin on Sat, 12 Sep 2020 21:47:02 GMT

Steps to Reproduce

  1. Create an empty macOS project
  2. Make a call to NetworkInterface.GetAllNetworkInterfaces()
  3. Have it signed and notarized
  4. Run the app on macOS Mojave

Expected Behavior

Method should return an array of network interfaces including (but not limited to) a loopback interface

Actual Behavior

The method returns an empty array when executing the notarized app on Mojave but correctly returns an array of network interfaces when running through the debugger on any OS or when running the notarized app on Catalina or Big Sur. Adding additional network entitlements (such as com.apple.security.network.client or com.apple.security.network.server) has no effect.

Environment

=== Visual Studio Community 2019 for Mac === 

Version 8.7.6 (build 2)
Installation UUID: 12ab106d-0849-43ef-94a6-724b2182533f
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

Package version: 612000093

=== Mono Framework MDK ===

Runtime:
Mono 6.12.0.93 (2020-02/620cf538206) (64-bit)
Package version: 612000093

=== Roslyn (Language Service) ===

3.7.0-6.20412.3+d3c3a44a4e7ad31cc75c59be0d3df4a19ff33878

=== NuGet ===

Version: 5.7.0.6702

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.1.402/Sdks
SDK Versions:
3.1.402
3.1.302
3.1.301
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
3.1.8
3.1.6
3.1.5
2.1.22
2.1.20
2.1.19

=== Xamarin.Profiler ===

Version: 1.6.15.68
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 11.3.1 (15715)
Build 11C505

=== Xamarin.Mac ===

Version: 6.20.2.2 (Visual Studio Community)
Hash: 817b6f72a
Branch: d16-7
Build date: 2020-07-18 18:44:59-0400

=== Xamarin.iOS ===

Xamarin.iOS not installed.
Can't find mtouch or the Version file at /Library/Frameworks/Xamarin.iOS.framework/Versions/Current.

=== Xamarin Designer ===

Version: 16.7.0.495
Hash: 03d50a221
Branch: remotes/origin/d16-7-vsmac
Build date: 2020-08-28 13:12:52 UTC

=== Xamarin.Android ===

Version: 11.0.2.0 (Visual Studio Community)
Commit: xamarin-android/d16-7/025fde9
Android SDK: /Users/guygodin/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
7.1 (API level 25)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.5
SDK Build Tools Version: 29.0.2

Build Information: 
Mono: 83105ba
Java.Interop: xamarin/java.interop/d16-7@1f3388a
ProGuard: Guardsquare/proguard/proguard6.2.2@ebe9000
SQLite: xamarin/sqlite/3.32.1@1a3276b
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-7@017078f

=== Microsoft OpenJDK for Mobile ===

Java SDK: /Users/guygodin/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.7.0.13
Hash: 8380518
Branch: remotes/origin/d16-7~2
Build date: 2020-08-19 22:18:28 UTC

=== Android Device Manager ===

Version: 16.7.0.24
Hash: bb090a3
Branch: remotes/origin/d16-7
Build date: 2020-08-19 22:18:52 UTC

=== Build Information ===

Release ID: 807060002
Git revision: f69dff5c1e88ec0d76d7fab567c69339ef02862b
Build date: 2020-09-09 04:56:43-04
Build branch: release-8.7
Xamarin extensions: f69dff5c1e88ec0d76d7fab567c69339ef02862b

=== Operating System ===

Mac OS X 10.14.6
Darwin 18.7.0 Darwin Kernel Version 18.7.0
    Mon Apr 27 20:09:39 PDT 2020
    root:xnu-4903.278.35~1/RELEASE_X86_64 x86_64

Copied from original issue xamarin/xamarin-macios#9625

@rolfbjarne
Copy link
Member Author

From @rolfbjarne on Mon, 14 Sep 2020 13:05:42 GMT

I can reproduce this behavior, but I'm not sure we can do much about it, since it sounds like a bug in Mojave. In any case I'll move this to the mono repository, which is where the corresponding networking code resides.

Test app: mactestapp.git-c8ce6f0.zip

@nixtar
Copy link

nixtar commented Nov 3, 2020

I encountered this while going down the Notarization rabbit hole recently.
After testing various runtime exceptions in my Entitlements.plist I discovered that the entitlement "Allow DYLD Environment Variables" (com.apple.security.cs.allow-dyld-environment-variables) is required for the GetAllNetworkInterfaces method.

If you look deep within a stacktrace of the return of NetworkInterface.GetAllNetworkInterfaces() you will see something along the lines of:
System.TypeInitializationException: The type initializer for 'System.Net.NetworkInformation.SystemNetworkInterface' threw an exception. ---> System.DllNotFoundException: libc.dylib assembly: type: member:(null)

Hope this helps, perhaps the "fix" from mono's side could be to ensure an exception is thrown all the way up when something this deep fails?

@SamMonoRT SamMonoRT assigned lambdageek and unassigned imhameed Mar 2, 2022
@SamMonoRT
Copy link
Contributor

@lambdageek - sending this your way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Runtime: Interop os-macOS target-xamarin-mac if shared with iOS use target-xamarin-ios
Projects
None yet
Development

No branches or pull requests

5 participants