0 votes
by (170 points)

Hello guys !

I'm trying to use Rebex for FTP/SSL secure connection.

Right now, i just have a little ftp server.

If i used this following code , it works perfectly :

var ftp = new Rebex.Net.Ftp(); 
ftp.Connect("192.168.1.133", 2221);         
ftp.Login("anonymous", "");

But i need to secure this. That's why i tried to use the SslMode.Explicit
Then i used this :

var ftp = new Rebex.Net.Ftp(); 
ftp.Connect("192.168.1.133", 2221, SslMode.Explicit);         
ftp.Login("anonymous", "");

And i don't uderstand why i have this error :

Unhandled Exception:

System.ArgumentException: Argument passed in is not serializable.
Parameter name: value

I found nothing anywhere, that's why i'm a little bit confused.

What i'm doing wrong ?

*Sorry for my very bad english, i'm don't speak english very well :3

Thanks for reading me !

Applies to: Rebex FTP/SSL

1 Answer

0 votes
by (148k points)
edited by
 
Best answer

Hello,

Update: The "Argument passed in is not serializable" exception was thrown due to a breaking change in Xamarin.Android instead of another exception. This has been fixed in version 2017 R3 of Rebex components.

Please try running the code below. It will create rebex-log.txt file that should contain sufficient information for us to tell what is going on. Either post the log here or mail it to support@rebex.net

var log = new Rebex.FileLogWriter("rebex-log.txt", Rebex.LogLevel.Debug);
try
{
    var ftp = new Rebex.Net.Ftp();
    ftp.LogWriter = log;
    ftp.Connect("192.168.1.133", 2221, SslMode.Explicit);
    ftp.Login("anonymous", "");
}
catch (Exception error)
{
    log.Write(LogLevel.Error, typeof(object), 0, "Custom", error.ToString());
    throw;
}
by (170 points)
Hello,

Thanks for the quick answer, it's really impressive !

Here is the rebex-log.txt :

System.ArgumentException: Argument passed in is not serializable.
Parameter name: value
  at System.Collections.ListDictionaryInternal.set_Item (System.Object key, System.Object value) [0x00056] in /Users/builder/data/lanes/4009/3a62f1ea/source/mono/mcs/class/referencesource/mscorlib/system/collections/listdictionaryinternal.cs:61
  at Rebex.Net.FtpException.NE (Rebex.Net.FtpResponse Z) [0x00031] in <6ec8d5f3f62a4b8bb1098f4ae2b7edbe>:0
  at Rebex.Net.FtpException..ctor (Rebex.Net.FtpResponse Z, System.Exception T) [0x0006e] in <6ec8d5f3f62a4b8bb1098f4ae2b7edbe>:0
04-04 19:39:43.232 I/mono-stdout( 9334): Parameter name: value
04-04 19:39:43.242 I/mono-stdout( 9334):   at System.Collections.ListDictionaryInternal.set_Item (System.Object key, System.Object value) [0x00056] in /Users/builder/data/lanes/4009/3a62f1ea/source/mono/mcs/class/referencesource/mscorlib/system/collections/listdictionaryinternal.cs:61
04-04 19:39:43.242 I/mono-stdout( 9334):   at Rebex.Net.FtpException.NE (Rebex.Net.FtpResponse Z) [0x00031] in <6ec8d5f3f62a4b8bb1098f4ae2b7edbe>:0
04-04 19:39:43.242 I/mono-stdout( 9334):   at Rebex.Net.FtpException..ctor (Rebex.Net.FtpResponse Z, System.Exception T) [0x0006e] in <6ec8d5f3f62a4b8bb1098f4ae2b7edbe>:0
04-04 19:39:43.242 I/mono-stdout( 9334):   at Rebex.Net.FtpException..ctor (Rebex.Net.FtpResponse response) [0x00000] in <6ec8d5f3f62a4b8bb1098f4ae2b7edbe>:0
  at Rebex.Net.FtpException..ctor (Rebex.Net.FtpResponse response) [0x00000] in <6ec8d5f3f62a4b8bb1098f4ae2b7edbe>:0
  at Rebex.Net.Ftp.XO (Rebex.Net.TlsParameters Z, Rebex.Net.FtpSecureUpgradeType T) [0x00084] in <6ec8d5f3f62a4b8bb1098f4ae2b7edbe>:0
04-04 19:39:43.242 I/mono-stdout( 9334):   at Rebex.Net.Ftp.XO (Rebex.Net.TlsParameters Z, Rebex.Net.FtpSecureUpgradeType T) [0x00084] in <6ec8d5f3f62a4b8bb1098f4ae2b7edbe>:0

I'm not sure this is good because i'd some problems with Rebex.FileLogriter(AccesDenied).

Tell me if i'm doing wrong, i'll try some tips for writing in a .txt

Thanks again !
by (148k points)
Thanks, the exception message and stack trace is sufficient.

Which version and edition of Rebex FTP/SSL do you use, and on which platform? This looks like a compatibility issue in Xamarin.iOS edition of Rebex.Networking that has been fixed in version 2017 R1: http://www.rebex.net/ftp-ssl.net/history.aspx#2017R1

However, an equivalent issue has been discovered in Xamarin.Android edition and it's quite possible it might occur with some version of Mono as well. In any case, once we know the platform and version details I asked above, we would publish a hotfix shortly. Thanks for bringing this issue to our attention.
by (170 points)
Hello !

Thanks again for helping me !

I'm using the 2017.1v of rebex FTP/SSL (downloaded here : https://components.xamarin.com/view/Rebex-Ftp)

I'm using visual studio 2017 community with xamarin 4.3.0.795 / xamarin.Android SDK 7.1.0.42 and xamarin.IOS SDK 10.6.0.9 (btw, i'm deploying on an Android 4.4.2)

Hope this is sufficient !

Thanks again for the help !
by (148k points)
Please download the current build of Rebex FTP/SSL for Xamarin and give it a try - it should fix this issue: http://www.rebex.net/getfile/49956c044f1141e8b263abeccd779a3b/Rebex-Ftp-1.6305.xam

This is a trial version - if you already have a Rebex FTP/SSL license, please let me know and I will send you a link to a full version.
by (170 points)
Hello !

Hmmm sry for this, but i downloaded the file (and rebex on the website)

And actually i don't know how can i use the .xam file :S (i'm using the trial version btw)
by (58.9k points)
edited by
You will have to install the beta version manually via the *xpkg* tool from Xamarin:

The package you need to download:
http://www.rebex.net/getfile/49956c044f1141e8b263abeccd779a3b/Rebex-Ftp-1.6305.xam

Then download the tool from here:
https://components.xamarin.com/submit/xpkg

Then open the console and execute the following command:

- on Windows:

xamarin-component.exe install Rebex-Ftp.1.6305.xam

- on macOS:

mono xamarin-component.exe install Rebex-Ftp.1.6305.xam

This will instal the package locally to your Visual Studio/Xamarin Studio, so once you click on the "Components" section, you will see the locally installed package there and you will be able to add it to your project.
by (170 points)
Hello !

Thanks for the quick answer.

Unfortunately it seems like i'm stupid because i can't the new package.

Is there any path or name to find it ?
I searched on VisualStudio and for new rebex's files on my computer but there is nothing new.

Sorry for that, and thanks again for the help
by (58.9k points)
It seems that instaling *.xam file is not so user friendly.

Could you please download this zip package http://www.rebex.net/getfile/ab114c014a284b20a98e9b042640e740/Rebex-Ftp-1.6305.zip

unpack it and the manually add references to your project in Visual Studio/Xamarin Studio?

If your project targets Xamarin.Android you will find it in the "lib/android" folder.

Let me know if it helped.
by (170 points)
Hello guys !

Yay it's working now :D

Big thanks to you guys !

Amazing staff, it's incredible.

I'm just curious about one thing "This will instal the package locally to your Visual Studio". Where can i find these "locally file " ?

Thanks again guys, it's amazing, The Rebex staff is realy impressive. Fast and efficiency.

Hope the best for all of you !
by (170 points)
Hm

My bad. I was using the SslMode.None (for test) That's why it was working.

I've still the same problem, with the same error.

Thanks again for helping me.
by (58.9k points)
Well, if the issue persists with the beta version please create a new log file and either post the log here or send it to support@rebex.net.
Here is a detailed description how to create the log file.  http://www.rebex.net/kb/logging/default.aspx

Please make sure to not only send us the stacktrace but the log!
by (148k points)
This is very strange - are you sure you are in fact using the hotfix build? If you are, can you please post an updated exception stack trace?

The locally installed packages are stored in %LocalAppData%\Xamarin\Cache\Components  (in Windows) - please refer to https://kb.xamarin.com/customer/portal/articles/1865772-where-are-the-components-stored-on-my-machine for more information.
by (170 points)
edited by
Hello !

I don't know why it wasn't working before, but i change the .dll (i downloaded them again) and it change.

Right now i'm testing 2 things :

try
            {
                ftp.Connect("192.168.1.133", 2221, Rebex.Net.SslMode.Explicit);
                ftp.Login("hello", "pswd");
            }
            catch (Exception e)
            {
                Console.WriteLine("Error in first : {0}", e);
            }

(Local ftp server working perfectly) and this one

try
            {
                ftp.Connect("speedtest.tele2.net", Rebex.Net.SslMode.Explicit);
                ftp.Login("anonymous", "");
            }
            catch (Exception e)
            {
                Console.WriteLine("Error in second : {0}", e);
            }

The first gave me this error :

Rebex.Net.FtpException: Service is unavailable (431).
  at Rebex.Net.Ftp.EY (Rebex.Net.TlsParameters U, Rebex.Net.FtpSecureUpgradeType T) [0x000aa] in <305a1cb714ed4a77948ebd75fd5025d4>:0
  at Rebex.Net.Ftp.UX (System.String U, System.Int32 T, Rebex.Net.TlsParameters Z, Rebex.Net.SslMode M, Rebex.Net.FtpSecureUpgradeType N) [0x00a0b] in <305a1cb714ed4a77948ebd75fd5025d4>:0

It seems like it's a problem with my server.
But i don't understand the second one :

Rebex.Net.FtpException: Please login with USER and PASS (530).
  at Rebex.Net.Ftp.EY (Rebex.Net.TlsParameters U, Rebex.Net.FtpSecureUpgradeType T) [0x000aa] in <305a1cb714ed4a77948ebd75fd5025d4>:0
  at Rebex.Net.Ftp.UX (System.String U, System.Int32 T, Rebex.Net.TlsParameters Z, Rebex.Net.SslMode M, Rebex.Net.FtpSecureUpgradeType N) [0x00a0b] in <305a1cb714ed4a77948ebd75fd5025d4>:0

But i'm using the ftp.Login(). I tried with a couple of login/password but i got the same error.

Btw i trie this one right now :

 try
            {
                ftp.Connect("speedtest.tele2.net");
                ftp.Login("anonymous", "");
            }
            catch (Exception e)
            {
                Console.WriteLine("Error in third : {0}", e);
            }

and it works perfectly any idea ?

It's gonna working ! :D Thanks for the help !
by (148k points)
Great, this looks better!

It looks like the two servers don't support FTP over TLS/SSL. When the client issues "AUTH TLS" command (used to start TLS/SSL negotiation), one server responds with "431 Service is unavailable" error message and the other one responds with "530 Please login with USER and PASS". In both cases, this means that the server is not configured to support TLS/SSL. Third-party FTP clients such as FileZilla Client or WinSCP would fail with the same exception as well. The "530 Please login with USER and PASS" seems to be a common issue with vsftpd server - perhaps http://www.linuxquestions.org/questions/linux-server-73/problem-with-ssl-and-vsftpd-receiving-error-530-this-ftp-server-is-anonymous-only-562839/ might be helpful.
by (170 points)
Hello !

Yeah, i expected that.

I'll try to use a new server FTP.

Be right back !

Thnks again for the amazing help guys !
by (170 points)
edited by
Hello guys !

Thanks again for the hotfix, it seems like it works perfectly.

I've just a last error.

I use a Java serveur.
When i'm trying to connect myself to the server, i've got one error.
Ffs, the error message is changing all time. Now i got this one :

Rebex.Net.TlsException: An exception occurred in certificate verifier. ---> Rebex.Net.TlsException: An exception occurred in certificate verifier. ---> Rebex.Net.TlsException: An exception occurred in certificate verifier. ---> Rebex.Net.TlsException: An exception occurred in certificate verifier. ---> System.Security.Cryptography.CryptographicException: Unable to create native certificate chain. ---> Java.Security.Cert.CertificateException: java.security.NoSuchAlgorithmException: CertificateFactory PKIX implementation not found ---> Java.Security.NoSuchAlgorithmException: CertificateFactory PKIX implementation not found
   --- End of inner exception stack trace ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
  at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00082] in /Users/builder/data/lanes/4468/b16fb820/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:12649
  at Java.Interop.JniPeerMembers+JniStaticMethods.InvokeObjectMethod (System.String encodedMember, Java.Interop.JniArgumentValue* parameters) [0x0001b] in /Users/builder/data/lanes/4468/b16fb820/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniStaticMethods.cs:97
  at Java.Security.Cert.CertificateFactory.GetInstance (System.String type) [0x0001e] in /Users/builder/data/lanes/4468/b16fb820/source/monodroid/src/Mono.Android/platforms/android-25/src/generated/Java.Security.Cert.CertificateFactory.cs:250
  at Rebex.Security.Certificates.CertificateChain.L (Rebex.Security.Certificates.Certificate U, Rebex.Security.Certificates.CertificateStore T, System.Boolean Z) [0x00015] in <1b90e898d0e644a5be1aac11555f4df0>:0
   --- End of inner exception stack trace ---
  at Rebex.Security.Certificates.CertificateChain.L (Rebex.Security.Certificates.Certificate U, Rebex.Security.Certificates.CertificateStore T, System.Boolean Z) [0x00097] in <1b90e898d0e644a5be1aac11555f4df0>:0
  at Rebex.Security.Certificates.CertificateChain.O (Rebex.Security.Certificates.CertificateChainEngine U, Rebex.Security.Certificates.Certificate T, Rebex.Security.Certificates.CertificateStore Z, System.String M, Rebex.Security.Certificates.ValidationOptions N) [0x00078] in <1b90e898d0e644a5be1aac11555f4df0>:0
  at Rebex.Security.Certificates.CertificateChain.Validate (System.String serverName, Rebex.Security.Certificates.ValidationOptions options, Rebex.Security.Certificates.CertificateChainEngine engine) [0x0003f] in <1b90e898d0e644a5be1aac11555f4df0>:0
  at Rebex.Security.Certificates.CertificateChain.Validate (System.String serverName, Rebex.Security.Certificates.ValidationOptions options) [0x00000] in <1b90e898d0e644a5be1aac11555f4df0>:0
  at Rebex.Net.CertificateVerifier+YAM.Verify (Rebex.Net.TlsSocket socket, System.String commonName, Rebex.Security.Certificates.CertificateChain certificateChain) [0x00028] in <8086db98fbdf47ca87fe1885c7c2e095>:0
  at Rebex.Net.OAM.Verify (Rebex.Net.TlsSocket socket, System.String commonName, Rebex.Security.Certificates.CertificateChain certificateChain) [0x000ca] in <8086db98fbdf47ca87fe1885c7c2e095>:0
  at Rebex.Net.KGM.RM (System.String U, Rebex.Security.Certificates.CertificateChain T) [0x00054] in <8086db98fbdf47ca87fe1885c7c2e095>:0
   --- End of inner exception stack trace ---
  at Rebex.Net.KGM.RM (System.String U, Rebex.Security.Certificates.CertificateChain T) [0x00090] in <8086db98fbdf47ca87fe1885c7c2e095>:0
  at Rebex.Net.KGM.HM (System.Byte[] U, System.Int32 T, System.Int32 Z, Rebex.Net.RGM M) [0x004d7] in <8086db98fbdf47ca87fe1885c7c2e095>:0
  at Rebex.Net.KGM.BT (System.Byte[] U, System.Int32 T, System.Int32 Z) [0x00073] in <8086db98fbdf47ca87fe1885c7c2e095>:0
  at Rebex.Net.WGM.OZ (System.Byte[] U, System.Int32 T, System.Int32 Z) [0x00093] in <8086db98fbdf47ca87fe1885c7c2e095>:0
  at Rebex.Net.WGM.XZ () [0x000e1] in <8086db98fbdf47ca87fe1885c7c2e095>:0
   --- End of inner exception stack trace ---
  at Rebex.Net.WGM.XZ () [0x0015e] in <8086db98fbdf47ca87fe1885c7c2e095>:0
  at Rebex.Net.WGM.JZ () [0x00059] in <8086db98fbdf47ca87fe1885c7c2e095>:0
  at Rebex.Net.TlsSocket.Negotiate () [0x000d9] in <8086db98fbdf47ca87fe1885c7c2e095>:0
  at Rebex.Net.LZM.AU (Rebex.Net.TlsParameters U) [0x000b1] in <305a1cb714ed4a77948ebd75fd5025d4>:0
   --- End of inner exception stack trace ---
  at Rebex.Net.Ftp.UX (System.String U, System.Int32 T, Rebex.Net.TlsParameters Z, Rebex.Net.SslMode M, Rebex.Net.FtpSecureUpgradeType N) [0x00299] in <305a1cb714ed4a77948ebd75fd5025d4>:0
   --- End of inner exception stack trace ---
  at Rebex.Net.Ftp.UX (System.String U, System.Int32 T, Rebex.Net.TlsParameters Z, Rebex.Net.SslMode M, Rebex.Net.FtpSecureUpgradeType N) [0x00acf] in <305a1cb714ed4a77948ebd75fd5025d4>:0

Seems like i've got an error with the certificate, i'll try to change it (i can't delete my com that's why this message is not very usefull)

EDIT : Okay it's working fine now ! :D
I just had to validate my custom certificate ( if someone wants it , you can find explanation here : http://www.rebex.net/ftp-ssl.net/features/tls-ssl.aspx#server-certificates )
Thanks alot for the previous help guys, amazing staff ;)


Thanks again for the help !
by (148k points)
This looks like parts of Android API related to certificate validation are missing or not accessible for Xamarin.Android apps for some reason. Using a custom certificate validator works around this problem, but it would still be useful to know what is going on. Which version of Android and Xamarin.Android do you use?
by (170 points)
Hello guy,

It's working perfectly (edited my previous message).
Of course, it was because i don't validate my own custom certificate.

After using this one  http://www.rebex.net/ftp-ssl.net/features/tls-ssl.aspx#server-certificates or client.Settings.SslAcceptAllCertificates = true; (for testing) it's working perfectly.

Thanks again for all the helps ! :)
...