[Mono-devel-list] SSLClientStream for FTPS - A message could not be decoded because some field was out of the specified range or the length of the message was incorrect.

Martin Hinks mhinks at gmail.com
Sat Jun 25 07:07:49 EDT 2005


Hi all,

I am currently writing the FX2.0 class System.Net.FtpWebRequest, which
features the EnableSSL Property. To implement this I am using an
SSLClientStream as follows for FTPS:

CertificateCollection certificates;
Mono.Security.Protocol.Tls.SslClientStream SSL;
Stream net;

//Negotiate TLS

//Load a cert just to test
System.Security.Cryptography.X509Certificates.X509Certificate cert =
System.Security.Cryptography.X509Certificates.X509Certificate.CreateFromCertFile("/home/w-h/Desktop/test.crt");

certificates.Add(cert);

//Local connect so have used hardcoded "127.0.0.1" until I can get this to work
//At this point net is a NetworkStream using my control connection socket
SSL = new Mono.Security.Protocol.Tls.SslClientStream(net, "127.0.0.1",
false, Mono.Security.Protocol.Tls.SecurityProtocolType.Tls,
certificates);

//Validation callback that always returns TRUE
SSL.ServerCertValidationDelegate = new
Mono.Security.Protocol.Tls.CertificateValidationCallback(CertificateValidator);

net = SSL;

//start the negotiation
//.SendCommand just uses net to send the data

this.SendCommand("PBSZ 0");


--------------------------

This gives the following output:

>>>> Write handshake record (769|Handshake)
    Record data (69 bytes))
    01 00 00 41 03 01 b8 80 ba 9a 1e d6 1e 85 23 2d 
    30 9b 70 a3 27 c0 50 7a a2 34 3e 88 b5 1a ca ee 
    7a ac f1 44 b8 64 00 00 1a 00 35 00 2f 00 0a 00 
    05 00 04 00 09 00 03 00 06 00 08 00 60 00 61 00 
    62 00 64 01 00 
    >>>> Write Alert (DecodeError|A message could not be decoded
because some field was out of the specified range or the length of the
message was incorrect.)
    Record data (2 bytes))
    01 32 

Unhandled Exception: System.IO.IOException: The authentication or
decryption has failed.
in [0x00131] (at
/home/w-h/Desktop/CD/TLSLib/TLS/SslClientStream.cs:848)
Mono.Security.Protocol.Tls.SslClientStream:NegotiateHandshake ()
in (wrapper remoting-invoke-with-check)
Mono.Security.Protocol.Tls.SslClientStream:NegotiateHandshake ()
in [0x00094] (at
/home/w-h/Desktop/CD/TLSLib/TLS/SslClientStream.cs:639)
Mono.Security.Protocol.Tls.SslClientStream:BeginWrite (System.Byte[]
buffer, Int32 offset, Int32 count, System.AsyncCallback callback,
System.Object state)
in [0x00006] (at
/home/w-h/Desktop/CD/TLSLib/TLS/SslClientStream.cs:740)
Mono.Security.Protocol.Tls.SslClientStream:Write (System.Byte[]
buffer, Int32 offset, Int32 count)
in [0x00041] (at /home/w-h/Desktop/CD/TLSLib/FTP/FTPWebRequest.cs:683)
System.Net.FtpWebRequest:SendCommand (System.String CommandText)
in (wrapper remoting-invoke-with-check)
System.Net.FtpWebRequest:SendCommand (string)
in [0x0009a] (at
/home/w-h/Desktop/CD/TLSLib/FTP/FTPWebRequest.cs:1069)
System.Net.FtpWebRequest:doOperations ()
in (wrapper delegate-invoke) System.MulticastDelegate:invoke_void ()


---------------------

This error is being thrown inside RecordProtocol.cs - in the
this.ReadRecordBuffer call.

Does anyone have any ideas?

-- 
Thanks, Martin Hinks



More information about the Mono-devel-list mailing list