MinimalFTP
MinimalFTP copied to clipboard
Q: Can you provide an example for an SSL enabled server?
Specifically, how do we create a simple SSLContext to pass in?
// Creates a native file system
File ftpRootDir = getFtpRootDir();
NativeFileSystem fs = new NativeFileSystem(ftpRootDir);
// Creates a noop authenticator, which allows anonymous authentication
NoOpAuthenticator auth1 = new NoOpAuthenticator(fs);
// Creates a secure SSL server with the noop authenticator
server3 = new FTPServer(auth1);
server3.setExplicitSSL(false); // support SSL connections
SSLContext sslContext = howDoWeBuildSimpleSSLContext(); // ???
server3.setSSLContext(sslContext);
// Start listening asynchronously
server3.listen(InetAddress.getLoopbackAddress(), 3333);
Second this. I'd like to use a self-signed certificate, but I cannot build a SSLContext that works.
I tried:
https://stackoverflow.com/questions/12411363/java-code-to-connect-to-ftp-server-using-ssl https://gist.github.com/erickok/7692592
Using sample certificates from:
https://github.com/freelan-developers/freelan/wiki/Sample-certificate-files
But can't get it work.