Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
19.5k views
in .NET FTP by (240 points)
When attempting to connect to an FTPS server, I get the ultimate error "Control channel unexpectedly closed ('' read so far)", but when looking at the trace messages I'm seeing a CryptographicException: "Couldn't acquire crypto service provider context (-2146885628)".

Here's a full dump of the connection attempt:

DEBUG [HostNameResolver] 12 Aug 2010 16:42:40.566 : partnerftp.destinationrewards.com resolved to 208.69.92.152
DEBUG [ExFTPControlSocket] 12 Aug 2010 16:42:40.566 : Connecting directly to ftp-server partnerftp.destinationrewards.com:990
ALL [AsyncResult] 12 Aug 2010 16:42:40.582 : WaitOne begin: 100 3
ALL [AsyncResult] 12 Aug 2010 16:42:40.613 : Notify setting completed: null 3
ALL [AsyncResult] 12 Aug 2010 16:42:40.613 : Notify setting wait: 3
ALL [SecureSocket] 12 Aug 2010 16:42:40.629 : Notify: SecureSocket.OnConnect
ALL [AsyncResult] 12 Aug 2010 16:42:40.629 : WaitOne end: True 3
DEBUG [SSLFTPControlSocket] 12 Aug 2010 16:42:40.629 : Beginning Ssl3 handshake.
DEBUG [SecureSocket] 12 Aug 2010 16:42:40.629 : Changing protocol to Ssl3
DEBUG [SSLFTPControlSocket] 12 Aug 2010 16:42:40.629 : Ssl3 handshake complete.
DEBUG [FTPControlSocket] 12 Aug 2010 16:42:40.629 : Setting socket timeout=120000
ALL [TransferBuffer] 12 Aug 2010 16:42:40.645 : TransferBuffer timeout=120000
ALL [SocketController] 12 Aug 2010 16:42:40.645 : SocketController timeout=120000
ALL [SecureSocket] 12 Aug 2010 16:42:40.645 : SecureSocket timeout=120000
ALL [TransferBuffer] 12 Aug 2010 16:42:40.645 : TransferBuffer timeout=120000
ALL [SocketController] 12 Aug 2010 16:42:40.645 : SocketController timeout=120000
ALL [SecureSocket] 12 Aug 2010 16:42:40.645 : SecureSocket timeout=120000
DEBUG [SocketController] 12 Aug 2010 16:42:40.645 : Processing hello
DEBUG [FTPControlSocket] 12 Aug 2010 16:42:40.660 : Command encoding=System.Text.ASCIIEncoding
DEBUG [ExFTPControlSocket] 12 Aug 2010 16:42:40.660 : Created control-socket: SocksContext=, ProxySettings=NoProxy, RemoteHost=partnerftp.destinationrewards.com, controlPort=990, timeout=120000
DEBUG [FTPControlSocket] 12 Aug 2010 16:42:40.691 : StrictReturnCodes=False
ERROR [SocketController] 12 Aug 2010 16:42:40.676 : OnReceive - caught exception - closing
ERROR [SocketController] 12 Aug 2010 16:42:40.676 : System.Security.Cryptography.CryptographicException: Couldn't acquire crypto service provider context (-2146885628)
ERROR [SocketController] 12 Aug 2010 16:42:40.676 :    at RBnIOlBjVFqSM5QkpXO.yU5hc9BMvuDK9jCsygg.WWxBWdQLm(Int32& , String )
ERROR [SocketController] 12 Aug 2010 16:42:40.676 :    at RBnIOlBjVFqSM5QkpXO.yU5hc9BMvuDK9jCsygg.s0ietbjkA()
ERROR [SocketController] 12 Aug 2010 16:42:40.676 :    at fxQCwxqux7Uvwrlq7g.dcX1mF3cp0R5ZBwIYY.KMAB3CHiHX()
ERROR [SocketController] 12 Aug 2010 16:42:40.676 :    at 0jdNlcVvUxMEGME52ln.TEYevwVoXDwoblmoJEo.SFkh5mlri(fMLXvZVOFUEMiSXZyCY )
ERROR [SocketController] 12 Aug 2010 16:42:40.676 :    at 0jdNlcVvUxMEGME52ln.TEYevwVoXDwoblmoJEo.ProcessMessage(fMLXvZVOFUEMiSXZyCY )
ERROR [SocketController] 12 Aug 2010 16:42:40.676 :    at qpixG0VABRrVjoFRJNn.RPwpKLVYXRsuSBiggJI.ntnBPBmxl(fZMc7srMYEm5aUKaAgM )
ERROR [SocketController] 12 Aug 2010 16:42:40.676 :    at 94mIcTrrdO2xlCJgKCN.ErHIfJrVcLjodk470HE.LDqs27n6f(Byte[] , Int32 , Int32 )
ERROR [SocketController] 12 Aug 2010 16:42:40.676 :    at JkwckgV11S5ygb63g2I.uYMLfQV9IPiWWObbMV0.nuCrPcbDH(Byte[] , Int32 , Int32 )
ERROR [SocketController] 12 Aug 2010 16:42:40.676 :    at JkwckgV11S5ygb63g2I.uYMLfQV9IPiWWObbMV0.rjuVakhEY(Byte[] , Int32 , Int32 )
ERROR [SocketController] 12 Aug 2010 16:42:40.676 :    at 58oqYmrsUZjR3i4dqGU.Ggbqc4rhIR4lFmgLZqE.ntnBPBmxl(IAsyncResult )
DEBUG [SocketController] 12 Aug 2010 16:42:40.738 : CloseConnection(e=Couldn't acquire crypto service provider context (-2146885628))
DEBUG [SocketController] 12 Aug 2010 16:42:40.738 : Shut down socket
DEBUG [SocketController] 12 Aug 2010 16:42:40.738 : Closed socket
DEBUG [TransferBuffer] 12 Aug 2010 16:42:40.738 : Close() called when open
DEBUG [SecureSocket] 12 Aug 2010 16:42:40.738 : OnHandshakeComplete(False,Couldn't acquire crypto service provider context (-2146885628))
ALL [AsyncResult] 12 Aug 2010 16:42:40.754 : Notify setting completed: null 4
ALL [AsyncResult] 12 Aug 2010 16:42:40.754 : Notify setting wait: 4
ERROR [FTPControlSocket] 12 Aug 2010 16:42:40.754 : Control channel unexpectedly closed ('' read so far)
orders|ControlChannelIOException when connecting: Control channel unexpectedly closed ('' read so far)
orders|Exception thrown when transmitting file: ControlChannelIOException:Control channel unexpectedly closed ('' read so far)



This is in a program that has been compiled in .Net 4.0. Unfortunately, I can't backport it to 3.5 anymore.

edtFTPnet/PRO connects just fine to other regular FTP sites, however.

16 Answers

0 votes
by (162k points)
What version of our DLL are you using?
0 votes
by (240 points)
It's version 7.1.0.20
0 votes
by (162k points)
Could you try disabling server validation to see if that works?
0 votes
by (162k points)
Please try this DLL:

http://www.enterprisedt.com/products/tm ... netPRO.zip

and let us know the result. We've made a change that *may* help but can't replicate your error yet.
0 votes
by (240 points)
Unfortunately we still get the same error, and we already had server validation disabled, too. At least, this is what's in the code:

((SecureFTPConnection)ftpConnection).ServerValidation = SecureFTPServerValidationType.None;
0 votes
by (240 points)
Also, when using the new version you posted, we're now getting this error reported on other sites:

230 User logged in, proceed
---> FEAT
502 Command FEAT not implemented


How can I make it suppress the FEAT command after it logs into sites?
0 votes
by (162k points)
Please contact support@enterprisedt.com for a beta version.

I've also made a mod that just ignores FEAT errors if it is not supported.
0 votes
by (162k points)
Ok, we've determined that the most likely cause of this problem is that the user that you are running with does not have permissions to access the key store.

It seems that it can be resolved by deleting the key stores for the user. You need to remove the directories below this directory for the user running the application:

C:\Users\username\AppData\Roaming\Microsoft\Crypto\RSA

I would simply rename the directories as xxx.old rather than deleting them - then it is easy to go back.

You may also need to do the same to the All Users RSA directory. This could be in C:\Documents and Settings of course for XP.

Please go back to your original DLL (not the patches you've downloaded) and try this.

The FEAT problem is fixed and will be fixed in the next release.
0 votes
by (360 points)
Ok, we've determined that the most likely cause of this problem is that the user that you are running with does not have permissions to access the key store.


I have a service that encounters this exception after a reboot. If I stop the service, run the same code, as the same user(***), in a Windows Form app, it works fine. Then I restart the service and it works fine ... until another reboot.

(*** the truth is that the code bases does Windows user impersonation much like here: http://stackoverflow.com/questions/3780 ... il-to-work)

Any ideas on this?
0 votes
by (162k points)
Have you tried deleting the key stores as above?

Categories

...