通过让我们加密公共和私有密钥来设置Java HTTPS服务器

时间:2018-11-04 16:21:08

标签: java ssl https lets-encrypt nanohttpd

如何使用let's encrypt免费证书服务设置基本的HTTPS服务器?

到目前为止,我跟随我们加密我的CentOS 7计算机上的设置,并得到以下不错的输出:

  

恭喜!您的证书和链条已保存在:
  /etc/letsencrypt/live/www.clashofstones.com/fullchain.pem您的密钥   文件已保存在:
  /etc/letsencrypt/live/www.clashofstones.com/privkey.pem您的证书   将于2019-02-01到期。

我看到了一些关于HTTPS设置的答案,但是它们都使用了 XDocument newxdoc = XDocument.Load(xmlfile); newxdoc.DescendantNodes().Where(e => e.NodeType.ToString().StartsWith("ProcessingInstruction")).Remove(); string newstringdoc = RemoveAllNamespaces(newxdoc.ToString()); newxdoc = XDocument.Parse(newstringdoc); 文件和一些密码,而这些密码我并没有输入。

*.keystore

我也碰上了nanohttpd,他们似乎支持HTTPS,但是我没有找到示例。

应该这样使用:

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

所以我的问题是如何使用NanoHTTPD myServer = new NanoHTTPD(port); SSLServerSocketFactory sslServerSocketFactory; String[] sslProtocols; myServer.makeSecure(sslServerSocketFactory, sslProtocols); myServer.start(timeOut, isDeamon); sslServerSocketFactory文件构造sslProtocolsfullchain.pem

0 个答案:

没有答案