robinrodricks / FluentFTP

An FTP and FTPS client for .NET & .NET Standard, optimized for speed. Provides extensive FTP commands, File uploads/downloads, SSL/TLS connections, Automatic directory listing parsing, File hashing/checksums, File permissions/CHMOD, FTP proxies, FXP support, UTF-8 support, Async/await support, Powershell support and more. Written entirely in C#.
MIT License
3.07k stars 649 forks source link

FluentFtp.GnuTls client side connection to server on MacOS #1632

Open bow-meow opened 1 month ago

bow-meow commented 1 month ago

FTP Server OS: Mac

FTP Server Type: FileZilla

Client Computer OS: Mac

FluentFTP Version: FluentFTP Version= 50.1.0 FluentFTP.GnuTLS Version= 1.0.31

Framework: .NET 6

I saw that FluentFtp.GnuTls says it supports macOS, but when I try to use it to connect to an ftp server, it says it cannot find linux system files? Looking at the source code for FluentFtp.GnuTls, I see that it only really handles linux and windows. So is it not compatible with macOS?

FanDjango commented 1 month ago

It should work (but I have never done it):

You need to build (no need, really) or install GnuTLS and its helper libraries.

These need to be able to be found, we can discuss that some more, how to check.

Try with this: https://macappstore.org/gnutls/

FanDjango commented 1 month ago

We check the platform ID (https://learn.microsoft.com/de-de/dotnet/api/system.platformid?view=net-8.0) and accept "6", which is MacOSX.

bow-meow commented 1 month ago

Thank you FanDjango for your response. I have installed gnutls on my Mac but I'm still having problems.

Here is the exception I get:

Exception thrown: 'FluentFTP.GnuTLS.GnuTlsException' in System.Private.CoreLib.dll: 'GnuTLS .dll load/call validation error'
 Inner exceptions found, see $exception in variables window for more details.
 Innermost exception     System.DllNotFoundException : Unable to load shared library 'libdl.so.2' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(liblibdl.so.2, 0x0001): tried: 'liblibdl.so.2' (no such file), '/System/Volumes/Preboot/Cryptexes/OSliblibdl.so.2' (no such file), 

The extension of the file its trying to use is linux related which I wonder if that is the problem?

FanDjango commented 1 month ago

Ok. The fault seems to be that on MacOSX, there is no need to load ldlib.so.2 to be able to access dlerror, dlopen and dlclose.

I will try to make a change to cater for this, then send you the link for a "special" branch of mine and you can test.

FanDjango commented 1 month ago

Can you first check if this is any help:

https://github.com/dotnet/dotnet-docker/discussions/4938#discussioncomment-7892892

FanDjango commented 1 month ago

And, if you set the environment variable DYLD_PRINT_LIBRARIES prior to your dotnet run, you will get debug output of all dll he is wanting to load, their exact names and where he is looking for them. You could then check if these are actually present at that location.

FanDjango commented 1 month ago

Note also that libdl is part of std set of libraries available on linux(-like) systems. we use it to load the gnutls dlls. So he is not even getting that far.

bow-meow commented 1 month ago

this sounds right

Ok. The fault seems to be that on MacOSX, there is no need to load ldlib.so.2 to be able to access dlerror, dlopen and dlclose.

I will try to make a change to cater for this, then send you the link for a "special" branch of mine and you can test.

this won't help as its for linux and these files don't exist on MacOS, the installation of gnutls does not come with those files as far as I can see

Can you first check if this is any help:

https://github.com/dotnet/dotnet-docker/discussions/4938#discussioncomment-7892892

I found this about libdl if it helps? https://github.com/att/ast/issues/295

I think the key thing here is that you're trying to use a file that does not exist on Mac, and it does not exist in the gnutls files downloaded.

I did notice that I was using home-brew arm64, which was installing gnutls to a different location than usr/local/.., and have now installed the 64bit version of home-brew with the 64bit version of gnutls which is installed to the correct location but im still getting the same issue where it tries to load a .so file which doesn't exist

FanDjango commented 1 month ago

Can you please find out on your Macosx if you have any libdl.* files in /usr/lib64/? Regardless of their name ending?

FanDjango commented 2 weeks ago

I was really hoping to get some information here to solve this problem. Well...