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 (147k 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 (147k 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 (147k 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 ! :)
...