Copy link to clipboard
Copied
Hi, hope somebody can help!
I'm running an evaluation on the new Coldfusion 9 and trying to use the <CFFTP> tag to connect to a remote SFTP server. The server version is:-
SSH-2.0-OpenSSH_4.7p1 Debian-8ubuntu1.2
My Code is:-
<cfftp action = "open"
username = "myusername"
connection = "MyConnection"
password = "mypassword"
server = "myserver.com"
secure = "yes">
<p>Successful: <cfoutput>#cfftp.succeeded#</cfoutput>
<cfdump var ="#MyConnection#" label="connection">
This is what is returned:-
An error occurred while establishing an sFTP connection. | |||||||||
Verify your connection attributes: username, password, server, fingerprint, port, key, connection, proxyServer, and secure (as applicable). Error: Session.connect: java.io.IOException: invalid data. | |||||||||
The error occurred in /Applications/ColdFusion9/wwwroot/test/sftp.cfm: line 12 | |||||||||
10 : 11 : server = "10.1.3.43" 12 : secure = "yes"> 13 : 14 : <p>Successful: <cfoutput>#cfftp.succeeded#</cfoutput> | |||||||||
Resources:
| |||||||||
|
Stack Trace |
at cfsftp2ecfm1948882534.runPage(/Applications/ColdFusion9/wwwroot/test/sftp.cfm:12) at cfsftp2ecfm1948882534.runPage(/Applications/ColdFusion9/wwwroot/test/sftp.cfm:12) com.jcraft.jsch.JSchException: Session.connect: java.io.IOException: invalid data at com.jcraft.jsch.Session.connect(Unknown Source) at com.jcraft.jsch.Session.connect(Unknown Source) at coldfusion.tagext.net.SftpHandler.getConnection(SftpHandler.java:265) at coldfusion.tagext.net.SftpHandler.createConnection(SftpHandler.java:76) at coldfusion.tagext.net.FtpTag.doStartTag(FtpTag.java:675) at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2722) at cfsftp2ecfm1948882534.runPage(/Applications/ColdFusion9/wwwroot/test/sftp.cfm:12) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:231) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:416) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:363) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:87) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:53) at coldfusion.CfmServlet.service(CfmServlet.java:200) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at jrun.servlet.FilterChain.doFilter(FilterChain.java:86) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at jrun.servlet.FilterChain.doFilter(FilterChain.java:94) at jrun.servlet.FilterChain.service(FilterChain.java:101) at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106) at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286) at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543) at jrun.servlet.http.WebService.invokeRunnable(WebService.java:172) at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320) at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428) at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266) at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66) |
I've tried running this from both a Mac and Windows platform.
Incidentally, I also took the example from the Adobe Coldfusion 9 live docs and got the same error.
If I can't get this to work then it's a show stopper for the use of CF within our environment.
Best Regards,
Carl Bourne
Message was edited by: CarlB Just tried using the above to connect to a SSH (SSH-2.0-OpenSSH_5.2) server running on MAC OSX. I got the same error.
Copy link to clipboard
Copied
server = "10.1.3.43"
And when you use the form server = "ftp.myserver.com"?
Copy link to clipboard
Copied
I'm having the same issue. Did you ever get this working? Did changing the IP address to the domain name work?
Copy link to clipboard
Copied
has this been fixed yet, as I am getting same error
Copy link to clipboard
Copied
check jsch library version, read this for details:
I replaced my jsch.jar with com.jcraft.jsch_0.1.32.jar from the post above:
Created an attachment (id=60352) [details]
This jar will specify "SunJCE" explicitly in using JCE API.
The attached jar will specify the JCE provider name "SunJCE" in
getting JCE instances. You have thought that you have only used the default
JCE provider and you may feel it is just a waste of time,
but please try it if possible.
Copy link to clipboard
Copied
That did not fix my problem specifically, but it is related, and it gave me enough insight to find a work-around without changing jar files.
It seems that ColdFusion loads "com.rsa.jsafe.provider.JsafeJCE" as the default security provider at startup. Perhaps there is something wrong with this provider like the “BC” provider mentioned in your link. Working with that, I was able to dump my providers into an array where the first array position represents the default provider and shows JsafeJCE as the default:
<cfset providerMethods = CreateObject('java','java.security.Security')>
You can dump the providers:
<cfdump var="#providerMethods.getProviders()#">
I then made a copy of the provider like:
<cfset jSafeProvider = providerMethods.getProvider('JsafeJCE')>
I then removed it from the provider array:
<cfset providerMethods.removeProvider('JsafeJCE')>
I then made my sFTP call and this time it was successful.
<cfftp action="open"
secure="true”…
I then put the provider back into the array in position 1 – the default:
<cfset providerMethods.insertProviderAt(jSafeProvider,1)>
I can’t say I know exactly what’s wrong and I certainly don’t want to remove the JsafeJCE provider from the default position for forever. I’ll let Adobe come up with a true fix, but for now, this provides me with a work-around so I can use sFTP. I’m sure JsageJCE is used/required for some other encryption, so you’ll have to watch for other issues while it’s not part of the provider array. The quicker you can get it out/in, probably the better. My sFTP only runs a few times, so I feel OK with the possible side effects. Maybe someone can take it from here and find a better solution and not a simple work-around.
Copy link to clipboard
Copied
Thanks Neo! - your work-around saved my project. Running CF 9.0.1 and couldn't connect for nothing. I added your code and it connects as expected. I unfortunately lost the jSafeProvider during an error on the cfftp "open" tag, so the Provider was not written back as the default. Now I get jSafeProvider not defined error. Anyway to recover that?
Thanks again for posting your work-around.
Mark
Copy link to clipboard
Copied
Just store the provider a a variable before you remove it and add it back in after the operation is complete.
Copy link to clipboard
Copied
Hey Mark,
If you loose jSafeProvider because of errors happening before re-adding it to the provider list, you can restart your ColdFusion service and it should appear again.
Cheers,
Tom
Copy link to clipboard
Copied
Thanks Neo! That was exactly what I needed to.
Copy link to clipboard
Copied
This has been fixed in CF10 and sFTP works with no issues or work-around's, so just comment your code so you can remove it when you upgrade....
Copy link to clipboard
Copied