Setup java HTTPS server with let's encrypt public and private keys

967 Views Asked by At

How to set up a basic HTTPS server with let's encrypt free certificate service?

So far I followed let's encrypt setup on my CentOS 7 machine and got this nice output:

Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/www.clashofstones.com/fullchain.pem Your key file has been saved at:
/etc/letsencrypt/live/www.clashofstones.com/privkey.pem Your cert will expire on 2019-02-01.

I saw a few answers for HTTPS setup but they all use a *.keystore file and some password, which I didn't make.

char[] password = "simulator".toCharArray ();
KeyStore ks = KeyStore.getInstance ( "JKS" );
FileInputStream fis = new FileInputStream ( "lig.keystore" );
ks.load ( fis, password );

I also bump into nanohttpd, they seem to support HTTPS, but I didn't find an example for it.

It's supposed to be used like this:

NanoHTTPD myServer = new NanoHTTPD(port);
SSLServerSocketFactory sslServerSocketFactory;
String[] sslProtocols;
myServer.makeSecure(sslServerSocketFactory, sslProtocols);
myServer.start(timeOut, isDeamon);

So my question is to how to construct sslServerSocketFactory and sslProtocols using fullchain.pem and privkey.pem files.

0

There are 0 best solutions below