補充1:
已解決20的部分問題,移步這里
單域名下多子域名同時認證HTTPS
補充2:
之前忘了說了,我這個方法只對Tomcat7.0以上有用(要不然就是8.0...)
我自己用的是9.0
原因好像是因為7.0(還是8.0)才新增的對證書配置方法的支持,也就是這里:

7.0以下這一步應該是過不去的
----------------------正文----------------------------
1,下載Let's Encrypt Windows認證客戶端
http://files.cnblogs.com/files/teamblog/letsencrypt-win-simple.V1.9.1.zip
2,解壓縮,打開letsencrypt.exe
3,設置提醒郵箱

4,按Y同意條款

5,按M方式認證

6,在你想要上https的域名的后台文件里,加入對"/.well-known/acme-challenge/*"形式訪問的處理
因為Let's Encrypt要驗證你的域名是否屬於你,會在你剛剛解壓縮文件夾下生成一個驗證文件,這里*是生成是隨機字符
就比如:

這是我服務器上解壓路徑(我給放到桌面了),驗證時候(第七,第八步)會生成一個要驗證域名的文件夾,里面存放着驗證文件,如下圖:

SpringMVC形式驗證的代碼如下,其他方式自行實現:
@RequestMapping("/.well-known/acme-challenge/*")
public ResponseEntity<String> check(HttpServletRequest request, HttpServletResponse response){
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.set("Content-Type", "application/json;charset=UTF-8");
String result="";
try {
String URI=request.getRequestURI().replace("/","\\");
//文件路徑自行替換一下就行,就是上圖中生成驗證文件的路徑,因為URI中已經包含了/.well-known/acme-challenge/,所以這里不需要
File file=new File("C:\\Users\\Administrator\\Desktop\\letsencrypt-win-simple.V1.9.1\\www.gutongxue.com\\"+URI);
InputStream is = new FileInputStream(file);
// 設置response參數,可以打開下載頁面
response.reset();
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setHeader("Content-Disposition", "attachment;filename="+ new String(("驗證文件").getBytes(), "iso-8859-1"));
ServletOutputStream out = response.getOutputStream();
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
bis = new BufferedInputStream(is);
bos = new BufferedOutputStream(out);
byte[] buff = new byte[2048];
int bytesRead;
// Simple read/write loop.
while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
bos.write(buff, 0, bytesRead);
}
} catch (final IOException e) {
throw e;
} finally {
if (bis != null)
bis.close();
if (bos != null)
bos.close();
}
}catch (Exception e){
}
return new ResponseEntity<String>(result, responseHeaders, HttpStatus.OK);
}
7,輸入你想轉為https的域名
8,驗證文件的域名(如果用我的代碼,就還輸入你的域名就行,驗證原理是訪問你輸入的值+/.well-known/acme-challenge/+生成的隨機碼)

9,證書到這里就生成成功了

10,由於Let's Encrypt是免費的SSL證書,90天就過期了,需要再次認證,貼心的Let's Encrypt客戶端程序會自動幫你生成驗證腳本,不要關閉窗口,繼續往下走就行
11,確認幫你創建定時任務(不確定的話90天后SSL證書過期,就不是https了)

12,輸入該計算機(服務器)的管理員帳號密碼

13,證書部分完成,可以關閉該窗口了

14,找到生成的證書文件,默認路徑在 C:\Users\Administrator\AppData\Roaming\letsencrypt-win-simple\httpsacme-v01.api.letsencrypt.org\ ,主要使用下圖三個文件:

15,裝ARP環境(沒有這一步Tomcat啟不起來(未驗證))
http://tomcat.apache.org/download-native.cgi
下載這個

解壓縮,把服務器對應位數(32/64位)的tcnative-1.dll粘貼至C:\Program Files\Java\jre1.8.0_112\bin路徑下

注:32位的就在壓縮包的bin目錄下
16,配置Tomcat(注:我也是第一次做,一頭霧水不明白原理,以下配置我這里可以成功,至於說為什么這么做/你們不成功的原因,我也不知道...以后知道了再補充)
17,修改tomcat的conf目錄下server.xml文件:
搜索8443端口,第二個,去掉注釋,並改為這樣:

<Connector port="443" protocol="org.apache.coyote.http11.Http11AprProtocol" maxThreads="150" SSLEnabled="true" > <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" /> <SSLHostConfig> <Certificate certificateKeyFile="C:\Users\Administrator\AppData\Roaming\letsencrypt-win-simple\httpsacme-v01.api.letsencrypt.org\www.gutongxue.com-key.pem" certificateFile="C:\Users\Administrator\AppData\Roaming\letsencrypt-win-simple\httpsacme-v01.api.letsencrypt.org\www.gutongxue.com-crt.pem" certificateChainFile="C:\Users\Administrator\AppData\Roaming\letsencrypt-win-simple\httpsacme-v01.api.letsencrypt.org\www.gutongxue.com-chain.pem" type="RSA" /> </SSLHostConfig> </Connector>
這里就用到了之前證書生成的文件,對應着填就行
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
修改為:
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" />
<!-- <Connector port="8009" enableLookups="false" protocol="AJP/1.3" redirectPort="8443" /> -->
去掉注釋並修改為:
<Connector port="8009" enableLookups="false" protocol="AJP/1.3" redirectPort="443" />
18,修改tomcat的conf目錄下web.xml文件:

如圖位置,加入以下代碼:
<security-constraint> <web-resource-collection > <web-resource-name >SSL</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint>
19,重啟Tomcat,完成

20,已知問題:
多域名同一台服務器怎么弄?Tomcat那里怎么配?還需要多試試
子域名訪問時變成這個樣子...很尷尬啊...

