Guichaguri / MinimalFTP

A lightweight, simple FTP server. Pure Java, no dependencies.
Apache License 2.0
160 stars 45 forks source link

Q: Can you provide an example for an SSL enabled server? #5

Open bseib opened 5 years ago

bseib commented 5 years ago

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);
proofrock commented 5 years ago

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.