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

Error: "Undefined symbols for architecture arm64: _SSLClose" when building projects to iPad #101005

Closed
bearyung opened this issue Apr 13, 2024 · 7 comments
Assignees
Milestone

Comments

@bearyung
Copy link

bearyung commented Apr 13, 2024

Description

Repo project that demonstrates the issue: https://github.com/bearyung/test_ios

Open the project and build it to the physical iOS device (e.g. iPad with iOS 17.2)

Below error shows during deploying the project:

0>Xamarin.Shared.Sdk.targets(1559,3): Error : clang++ exited with code 1: Undefined symbols for architecture arm64: "_SSLClose", referenced from: _AppleCryptoNative_SslShutdown in libSystem.Security.Cryptography.Native.Apple.a(pal_ssl.c.o) "_SSLCopyALPNProtocols", referenced from: _AppleCryptoNative_SslGetAlpnSelected in libSystem.Security.Cryptography.Native.Apple.a(pal_ssl.c.o) "_SSLCopyDistinguishedNames", referenced from: _AppleCryptoNative_SslCopyCADistinguishedNames in libSystem.Security.Cryptography.Native.Apple.a(pal_ssl.c.o) "_SSLCopyPeerTrust", referenced from: _AppleCryptoNative_SslCopyCertChain in libSystem.Security.Cryptography.Native.Apple.a(pal_ssl.c.o) _AppleCryptoNative_SslIsHostnameMatch in libSystem.Security.Cryptography.Native.Apple.a(pal_ssl.c.o) "_SSLCreateContext", referenced from: _AppleCryptoNative_SslCreateContext in libSystem.Security.Cryptography.Native.Apple.a(pal_ssl.c.o) "_SSLGetNegotiatedCipher", referenced from: _AppleCryptoNative_SslGetCipherSuite in libSystem.Security.Cryptography.Native.Apple.

It seems .NET runtime still uses these deprecated API
https://github.com/dotnet/runtime/blame/v8.0.4/src/native/libs/System.Security.Cryptography.Native.Apple/pal_ssl.c#L594
https://developer.apple.com/documentation/security/1397869-sslclose

Reproduction Steps

mkdir test_ios
cd test_ios

dotnet new install Microsoft.iOS.Templates
dotnet new 

  1. Open the solution DemoNew with Rider created above
  2. Nuget the NetCoreServer v.8.0.7
  3. Create a simple TCP server (ChatServer.cs and ChatSession.cs in the sample repo)
  4. Run the Project in iOS Simulator (success)
  5. Run the project in iOS device (failed)

Expected behavior

The project should be able to build and run on iOS device, just like it can build and run on iOS simulators.

Actual behavior

The project should be able to compiled and run on iOS device.Target _LinkNativeExecutable:
Tool xcrun execution started with arguments: clang++ -mios-version-min=13.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.2.sdk -arch arm64 /Users/michaelyung/RiderProjects/test_ios/obj/Debug/net8.0-ios/ios-arm64/nativelibraries/aot-output/arm64/aot-instances.dll.o /Users/michaelyung/RiderProjects/test_ios/obj/Debug/net8.0-ios/ios-arm64/nativelibraries/aot-output/arm64/test_ios.dll.o
[ trimmed ]
0>Xamarin.Shared.Sdk.targets(1559,3): Error : clang++ exited with code 1:
Undefined symbols for architecture arm64:
"_SSLClose", referenced from:
_AppleCryptoNative_SslShutdown in libSystem.Security.Cryptography.Native.Apple.a(pal_ssl.c.o)
"_SSLCopyALPNProtocols", referenced from:
_AppleCryptoNative_SslGetAlpnSelected in libSystem.Security.Cryptography.Native.Apple.a(pal_ssl.c.o)
"_SSLCopyDistinguishedNames", referenced from:
_AppleCryptoNative_SslCopyCADistinguishedNames in libSystem.Security.Cryptography.Native.Apple.a(pal_ssl.c.o)
"_SSLCopyPeerTrust", referenced from:
_AppleCryptoNative_SslCopyCertChain in libSystem.Security.Cryptography.Native.Apple.a(pal_ssl.c.o)
_AppleCryptoNative_SslIsHostnameMatch in libSystem.Security.Cryptography.Native.Apple.a(pal_ssl.c.o)
"_SSLCreateContext", referenced from:
_AppleCryptoNative_SslCreateContext in libSystem.Security.Cryptography.Native.Apple.a(pal_ssl.c.o)
"_SSLGetNegotiatedCipher", referenced from:
_AppleCryptoNative_SslGetCipherSuite in libSystem.Security.Cryptography.Native.Apple.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Apr 13, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Tagging subscribers to this area: @dotnet/ncl, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

@vitek-karas
Copy link
Member

@ivanpovazan could you please take a look?

@ivanpovazan
Copy link
Member

It seems like we are not linking against Security framework.
@bearyung Could you try adding this to your project file and retry?

  <ItemGroup>
    <_LinkerFrameworks Include="Security" />
  </ItemGroup>

@bearyung
Copy link
Author

bearyung commented Apr 16, 2024

@ivanpovazan added the _linkerFrameworks as a workaround solved the issue, below is the fragment I've added to the project file:

  <!-- Manually add Security to the frameworks we link against. -->
  <Target Name="AddSecurity" Condition="'$(TargetFramework)' == 'net8.0-ios'" AfterTargets="_LoadLinkerOutput" BeforeTargets="_ComputeLinkNativeExecutableInputs">
    <ItemGroup>
      <_LinkerFrameworks Include="Security" />
    </ItemGroup>
  </Target>

@ivanpovazan
Copy link
Member

Glad it worked.
The fix has been merged in xamarin/xamarin-macios#20413 and will become available in the upcoming servicing releases (so the workaround will not be needed anymore).

For this reason, I will close the issue. Please feel free to reopen it if you encounter any other related problems.

@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Apr 16, 2024
@karelz karelz added this to the 9.0.0 milestone May 14, 2024
@StefanLaumann
Copy link

@bearyung I had the same problem, and your code snippet solved it for me :-)
Thanks a lot !!!

@github-actions github-actions bot locked and limited conversation to collaborators Jul 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants