DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Building Scalable Real-Time Apps with AstraDB and Vaadin
Register Now

Trending

  • How To Design Reliable IIoT Architecture
  • Chaining API Requests With API Gateway
  • Tomorrow’s Cloud Today: Unpacking the Future of Cloud Computing
  • Cypress Tutorial: A Comprehensive Guide With Examples and Best Practices

Trending

  • How To Design Reliable IIoT Architecture
  • Chaining API Requests With API Gateway
  • Tomorrow’s Cloud Today: Unpacking the Future of Cloud Computing
  • Cypress Tutorial: A Comprehensive Guide With Examples and Best Practices
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. ColdFusion and FTP over implicit TLS/SSL

ColdFusion and FTP over implicit TLS/SSL

John Whish user avatar by
John Whish
·
Jun. 05, 11 · News
Like (0)
Save
Tweet
Share
8.71K Views

Join the DZone community and get the full member experience.

Join For Free

Coldfusion 9 allows you to connect to a secure FTP server (cfftp: Opening and closing secure FTP server connections), however this doesn't seem  to work if the FTP server is using FTP over implicit TLS/SSL. To get it working was quite a head-ache and hopefully I can save someone else many hours of swearing!

Firstly if you are getting the error:

sun.security.validator.ValidatorException: 
PKIX path building failed: 
sun.security.provider.certpath.SunCertPathBuilderException: 
unable to find valid certification path to requested target

Then you may just need to add the certificate to your ColdFusion server. To do this I recommend using CertMan which you can download from http://certman.riaforge.org/.

That didn't work for me I was still getting this error:

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: connection is closed by foreign host.

So, then I started looking for Java libraries and found ftp4j which is licenced under the LGPL. Using it in ColdFusion is pretty simple if you use Mark Mandel's excellent JavaLoader.

So, download JavaLoader and extract into your webroot and then download ftp4j and put the ftp4j-1.6.jar in the webroot (if you're using mappings then you can put them anywhere).

Now that's done, here is some sample code to connect and list the directory contents of the FTP Server.

<cfscript>
paths = [];

/*
This points to the jar we want to load.
Could also load a directory of .class files
*/
paths[1] = expandPath("ftp4j-1.6.jar");

//create the loader
loader = createObject("component", "javaloader.JavaLoader").init(paths);

//at this stage we only have access to the class, but we don't have an instance
FTPClient = loader.create("it.sauronsoftware.ftp4j.FTPClient").init();

//FTPClient.setSecurity(FTPClient.SECURITY_FTPES); // enables FTPES
FTPClient.setSecurity(FTPClient.SECURITY_FTPS); // enables FTPS

// if the security is set to SECURITY_FTPS, the default port used by the connect() method changes to 990.
FTPClient.connect("ftps.someserver.com"); 

FTPClient.login("aliaspooryorik", "HardPasswordToGuess");

FTPClient.upload(CreateObject("java","java.io.File").init(ExpandPath("somefile.xml")));

writeDump(FTPClient.currentDirectory());

FTPClient.disconnect(true);
</cfscript>



File Transfer Protocol

Published at DZone with permission of John Whish, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • How To Design Reliable IIoT Architecture
  • Chaining API Requests With API Gateway
  • Tomorrow’s Cloud Today: Unpacking the Future of Cloud Computing
  • Cypress Tutorial: A Comprehensive Guide With Examples and Best Practices

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: