Forum Xamarin.Mac

Notarization issue

ClodoClodo ITMember ✭✭
edited June 2020 in Xamarin.Mac

I'm building a Xamarin.Mac (Full .Net Framework 4.8) with signing and notarization.
I have 3 macOS: High Sierra, Mojave, Catalina.
Visual Studio 8.6.4 (build 14).
Xamarin.Mac 6.18.0.23

My entitlements.plist contain only the "com.apple.security.cs.allow-jit=yes" entry.

If i made a build with "codesign --entitlements=... --options=runtime" (with a Success notarization) (even with manual codesign from commandline, or Visual Studio For Mac -> Mac Signing, don't matter)

works on Catalina,
works on High Sierra,
crash on Mojave (stack below). If i don't use entitlements and options=runtime, only signature, no notarization, NO exception.

Crash on Socket.Connect

Any tips? Thanks

F 2020.06.22 23:19:14 - Unable to start (The type initializer for 'System.Net.NetworkInformation.SystemNetworkInterface' threw an exception.
F 2020.06.22 23:19:14 -     at System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces () [0x00000] in <d99469ed03c64824842a05619517eb84>:0
F 2020.06.22 23:19:14 -     at System.Net.Sockets.Socket.IsProtocolSupported (System.Net.NetworkInformation.NetworkInterfaceComponent networkInterface) [0x00000] in <d99469ed03c64824842a05619517eb84>:0
F 2020.06.22 23:19:14 -     at System.Net.Sockets.Socket.InitializeSockets () [0x00024] in <d99469ed03c64824842a05619517eb84>:0
F 2020.06.22 23:19:14 -     at System.Net.Sockets.Socket..ctor (System.Net.Sockets.AddressFamily addressFamily, System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolType protocolType) [0x0003b] in <d99469ed03c64824842a05619517eb84>:0
F 2020.06.22 23:19:14 -     at Eddie.Core.Elevated.EleSocket.Connect (System.Int32 port) [0x00040] in <9261869d74a248ae9f7c9a163eb115c9>:0
F 2020.06.22 23:19:14 -     System.TypeInitializationException: The type initializer for 'System.Net.NetworkInformation.SystemNetworkInterface' threw an exception. ---> System.DllNotFoundException: libc.dylib assembly:<unknown assembly> type:<unknown type> member:(null)
F 2020.06.22 23:19:14 -     at (wrapper managed-to-native) System.Platform.uname(intptr)
F 2020.06.22 23:19:14 -     at System.Platform.CheckOS () [0x0001f] in <d99469ed03c64824842a05619517eb84>:0
F 2020.06.22 23:19:14 -     at System.Platform.get_IsMacOS () [0x00007] in <d99469ed03c64824842a05619517eb84>:0
F 2020.06.22 23:19:14 -     at System.Net.NetworkInformation.UnixNetworkInterfaceFactoryPal.Create () [0x0000f] in <d99469ed03c64824842a05619517eb84>:0
F 2020.06.22 23:19:14 -     at System.Net.NetworkInformation.NetworkInterfaceFactoryPal.Create () [0x00000] in <d99469ed03c64824842a05619517eb84>:0
F 2020.06.22 23:19:14 -     at System.Net.NetworkInformation.NetworkInterfaceFactory.Create () [0x00000] in <d99469ed03c64824842a05619517eb84>:0
F 2020.06.22 23:19:14 -     at System.Net.NetworkInformation.SystemNetworkInterface..cctor () [0x00000] in <d99469ed03c64824842a05619517eb84>:0
F 2020.06.22 23:19:14 -     --- End of inner exception stack trace ---
F 2020.06.22 23:19:14 -     at System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces () [0x00000] in <d99469ed03c64824842a05619517eb84>:0
F 2020.06.22 23:19:14 -     at System.Net.Sockets.Socket.IsProtocolSupported (System.Net.NetworkInformation.NetworkInterfaceComponent networkInterface) [0x00000] in <d99469ed03c64824842a05619517eb84>:0
F 2020.06.22 23:19:14 -     at System.Net.Sockets.Socket.InitializeSockets () [0x00024] in <d99469ed03c64824842a05619517eb84>:0
F 2020.06.22 23:19:14 -     at System.Net.Sockets.Socket..ctor (System.Net.Sockets.AddressFamily addressFamily, System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolType protocolType) [0x0003b] in <d99469ed03c64824842a05619517eb84>:0
F 2020.06.22 23:19:14 -     at Eddie.Core.Elevated.EleSocket.Connect (System.Int32 port) [0x00040] in <9261869d74a248ae9f7c9a163eb115c9>:0 )

Posts

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    This suggests that you don't have the required networking entitlements:

    Unable to obtain elevated privileges (required):

    See https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_network_client and related pages.

  • ClodoClodo ITMember ✭✭

    I removed from log of first post the text "Unable to obtain elevated privileges (required):" because it's a message in MY code.
    I added in entitlements.plist the network.client entry, don't change anything. And don't explain why works on Catalina and High Sierra, the issue occur ONLY in Mojave.
    Maybe related to the "System.DllNotFoundException: libc.dylib assembly", some linking issue?

  • ClodoClodo ITMember ✭✭

    I write this topic only because i hope in a quick workaround, maybe was a known issue.
    I will try to make an example, reproducible minimal project.

  • NixtarNixtar Member

    I have dealt with this issue with one of my apps.
    We don't use Socket.Connect but we do call NetworkInterface.GetAllNetworkInterfaces() and looking at your stacktrace so does Socket.Connect.

    In our case GetAllNetworkInterfaces() would return an empty array on Mojave when hardened runtime was enabled.

    After some googling and trial and error I discovered that "com.apple.security.cs.allow-dyld-environment-variables" is required for this method to function.

    Very likely due to the System.DllNotFoundException: libc.dylib assembly: type: member:(null) issue you noted, I also saw this when looking at a stacktrace for the return of GetAllNetworkInterfaces().

    Its quite strange that this is only required on Mojave, Catalina and even Big Sur 11.0.1 Beta 1 seems to not require this entitlement..
    Hope this helps :smile:

Sign In or Register to comment.