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 (220 points)
hi together,
i have the same problem here. yesterday i changed the user account which executes a windows task. the task executes a ftp-process and since i have changed the user, the process throw an exception:

ERROR: Connection to server 'XXX' could not be established!
Exception: EnterpriseDT.Mentalis.Security.SSLCryptographicException: Couldn't acquire crypto service provider context: Object already exists. [0x8009000f]


now i found this topic and wanted to delete the RSA subfolder. but there is no RSA folder. Not at the old user-folder whether at the new user folder. there are two folders that will be crteated new, if i rename the old ones:
"CLR Security Config" and "SystemCertificates". But the problem is not fixed.

if i return back to the old user-credentials it works perfect.

do you have another suggestions, how i can set a new user for executing the windows task?
thanks in advance.
0 votes
by (162k points)
It looks like a permissions problem. Try comparing the permissions of the user that works against the one that does not.
0 votes
by (220 points)
thanks for reply.
both users are have administrator rights on this machine...
the only one i could not try so far is a reboot. maybe this fix the problem!?
0 votes
by (51.6k points)
I think Bruce was referring to the access permissions of that directory, rather than the user-type. Open Windows Explorer, nagivate to the directory, right-click on it, select Properties, select the Security tab, then ensure that the user has permission to access that directory.

- Hans (EnterpriseDT)
0 votes
by (220 points)
hello hans,
thanks for your reply.
which directory do you mean? this one: "C:\Users\username\AppData\Roaming\Microsoft\Crypto\RSA".
such directory does not exist. at the directory "C:\Users\username\AppData\Roaming\Microsoft" there are five folders in: "CLR Security Config", "Credentials", "Internet Explorer", "SystemCertificates" and "Windows". the folders "CLR Security Config" and "SystemCertificates" will be created new, if i rename the old ones.

the user which executes the windows task has administrator rights at this machine. the user also have full permissions at the "C:\Users\username\AppData\Roaming\Microsoft" directory.
0 votes
by (162k points)
If you are running as a service, it'll use machine keys. Check the permissions on All Users\Microsoft\Crypto.

Categories

...