| 主機參考:VPS測評參考推薦/專注分享VPS服務器優惠信息!若您是商家可以在本站進行投稿,查看詳情!此外我們還提供軟文收錄、PayPal代付、廣告贊助等服務,查看詳情! |
| 我們發布的部分優惠活動文章可能存在時效性,購買時建議在本站搜索商家名稱可查看相關文章充分了解該商家!若非中文頁面可使用Edge瀏覽器同步翻譯!PayPal代付/收錄合作 |
阿里云SSL證書服務支持下載證書安裝到Jetty服務器,從而使Jetty服務器支持HTTPS安全訪問。本文介紹了證書安裝的具體操作。
1、Jetty服務器版本確認。建議使用Jetty 9.2.22及以上版本。
2、從阿里云下載tomcat格式的證書。非系統生成的CSR需要生成pfx證書密匙對文件,轉換命令如下。
openssl?pkcs12?-export?-out?214362464370691.pfx?-inkey?214362464370691.key?-in?214362464370691.pem
3、轉換pfx的證書密匙對文件為jks格式,轉換命令如下:
說明 Windows環境注意在%JAVA_HOME%/jdk/bin目錄中執行。
keytool?-importkeystore?-srckeystore?密匙對文件.pfx?-destkeystore?證書名稱.jks?-srcstoretype?PKCS12?-deststoretype?JKS
回車后輸入兩次要設置的jks格式證書密碼,然后輸入一次pfx證書密碼。三次密碼必須輸入pfx-password.txt記錄的密碼。jks密碼與pfx證書密碼相同,否則可能會導致Jetty服務器啟動失敗。
4、配置Jetty的SSL。
1)確保Jetty的http頁面可正常訪問。
2)拷貝證書。進入Jetty服務器目錄下的etc,新建存放jks格式證書的目錄,并復制jks格式證書至當前目錄。
#?pwd /opt/jetty9222/etc #?mkdir?cert #?cd?cert/ #?cp?../../../keys/jetty.jks?. #?ls jetty.jks
3)編輯Jetty服務器目錄下etc中的jetty-ssl.xml文件,設置證書相關參數(密碼設置為pfx-password.txt中記錄的所有密碼)。

<?xml?version="1.0"?> <!DOCTYPE?Configure?PUBLIC?"-//Jetty//Configure//EN"?"http://www.eclipse.org/jetty/configure_9_0.dtd"> <!--?=============================================================?--> <!--?Configure?a?TLS?(SSL)?Context?Factory?????????????????????????--> <!--?This?configuration?must?be?used?in?conjunction?with?jetty.xml?--> <!--?and?either?jetty-https.xml?or?jetty-spdy.xml?(but?not?both)???--> <!--?=============================================================?--> <Configure?id="sslContextFactory"?class="org.eclipse.jetty.util.ssl.SslContextFactory"> <Set?name="KeyStorePath"><Property?name="jetty.base"?default="."?/>/<Property?name="jetty.keystore"?default="etc/cert/jetty.jks"/></Set> <Set?name="KeyStorePassword"><Property?name="jetty.keystore.password"?default="214362464370691"/></Set> <?xml?version="1.0"?> <!DOCTYPE?Configure?PUBLIC?"-//Jetty//Configure//EN"?"http://www.eclipse.org/jetty/configure_9_0.dtd"> <!--?=============================================================?--> <!--?Configure?a?TLS?(SSL)?Context?Factory?????????????????????????--> <!--?This?configuration?must?be?used?in?conjunction?with?jetty.xml?--> <!--?and?either?jetty-https.xml?or?jetty-spdy.xml?(but?not?both)???--> <!--?=============================================================?--> <Configure?id="sslContextFactory"?class="org.eclipse.jetty.util.ssl.SslContextFactory"> <Set?name="KeyStorePath"><Property?name="jetty.base"?default="."?/>/<Property?name="jetty.keystore"?default="etc/cert/jetty.jks"/></Set> <Set?name="KeyStorePassword"><Property?name="jetty.keystore.password"?default="214362464370691"/></Set> <Set?name="KeyManagerPassword"><Property?name="jetty.keymanager.password"?default="214362464370691"/></Set> <Set?name="TrustStorePath"><Property?name="jetty.base"?default="."?/>/<Property?name="jetty.truststore"?default="etc/cert/jetty.jks"/></Set> <Set?name="TrustStorePassword"><Property?name="jetty.truststore.password"?default="214362464370691"/></Set> <Set?name="EndpointIdentificationAlgorithm"></Set> <Set?name="NeedClientAuth"><Property?name="jetty.ssl.needClientAuth"?default="false"/></Set> <Set?name="WantClientAuth"><Property?name="jetty.ssl.wantClientAuth"?default="false"/></Set> <Set?name="ExcludeCipherSuites"> <Array?type="String"> <Item>SSL_RSA_WITH_DES_CBC_SHA</Item> <Item>SSL_DHE_RSA_WITH_DES_CBC_SHA</Item> <Item>SSL_DHE_DSS_WITH_DES_CBC_SHA</Item> <Item>SSL_RSA_EXPORT_WITH_RC4_40_MD5</Item> <Item>SSL_RSA_EXPORT_WITH_DES40_CBC_SHA</Item> <Item>SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA</Item> <Item>SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA</Item> </Array> </Set> <!--?===========================================================?--> <!--?Create?a?TLS?specific?HttpConfiguration?based?on?the????????--> <!--?common?HttpConfiguration?defined?in?jetty.xml???????????????--> <!--?Add?a?SecureRequestCustomizer?to?extract?certificate?and????--> <!--?session?information?????????????????????????????????????????--> <!--?===========================================================?--> <New?id="sslHttpConfig"?class="org.eclipse.jetty.server.HttpConfiguration"> <Arg><Ref?refid="httpConfig"/></Arg> <Call?name="addCustomizer"> <Arg><New?class="org.eclipse.jetty.server.SecureRequestCustomizer"/></Arg> </Call> </New> </Configure>
4)編輯Jetty服務器目錄中的etc中的jetty-https.xml文件,配置https所使用的443端口。

<?xml?version="1.0"?> <!DOCTYPE?Configure?PUBLIC?"-//Jetty//Configure//EN"?"http://www.eclipse.org/jetty/configure_9_0.dtd"> <!--?=============================================================?--> <!--?Configure?a?HTTPS?connector.??????????????????????????????????--> <!--?This?configuration?must?be?used?in?conjunction?with?jetty.xml?--> <!--?and?jetty-ssl.xml.????????????????????????????????????????????--> <!--?=============================================================?--> <Configure?id="Server"?class="org.eclipse.jetty.server.Server"> <!--?===========================================================?--> <!--?Add?a?HTTPS?Connector.??????????????????????????????????????--> <!--?Configure?an?o.e.j.server.ServerConnector?with?connection???--> <!--?factories?for?TLS?(aka?SSL)?and?HTTP?to?provide?HTTPS.??????--> <!--?All?accepted?TLS?connections?are?wired?to?a?HTTP?connection.--> <!--?????????????????????????????????????????????????????????????--> <!--?Consult?the?javadoc?of?o.e.j.server.ServerConnector,????????--> <!--?o.e.j.server.SslConnectionFactory?and???????????????????????--> <!--?o.e.j.server.HttpConnectionFactory?for?all?configuration????--> <!--?that?may?be?set?here.???????????????????????????????????????--> <!--?===========================================================?--> <Call?id="httpsConnector"?name="addConnector"> <Arg> <New?class="org.eclipse.jetty.server.ServerConnector"> <Arg?name="server"><Ref?refid="Server"?/></Arg> <Arg?name="acceptors"?type="int"><Property?name="ssl.acceptors"?default="-1"/></Arg> <Arg?name="selectors"?type="int"><Property?name="ssl.selectors"?default="-1"/></Arg> <Arg?name="factories"> <Array?type="org.eclipse.jetty.server.ConnectionFactory"> <Item> <New?class="org.eclipse.jetty.server.SslConnectionFactory"> <Arg?name="next">http/1.1</Arg> <Arg?name="sslContextFactory"><Ref?refid="sslContextFactory"/></Arg> </New> </Item> <Item> <New?class="org.eclipse.jetty.server.HttpConnectionFactory"> <Arg?name="config"><Ref?refid="sslHttpConfig"/></Arg> </New> </Item> </Array> </Arg> <Set?name="host"><Property?name="jetty.host"?/></Set> <Set?name="port"><Property?name="https.port"?default="443"?/></Set> <Set?name="idleTimeout"><Property?name="https.timeout"?default="30000"/></Set> <Set?name="soLingerTime"><Property?name="https.soLingerTime"?default="-1"/></Set> <Set?name="acceptorPriorityDelta"><Property?name="ssl.acceptorPriorityDelta"?default="0"/></Set> <Set?name="selectorPriorityDelta"><Property?name="ssl.selectorPriorityDelta"?default="0"/></Set> <Set?name="acceptQueueSize"><Property?name="https.acceptQueueSize"?default="0"/></Set> </New> </Arg> </Call> </Configure>
5)編輯Jetty服務器目錄下的start.ini文件,根據需要更改端口號,設置啟動加載jetty-https.xml、jetty-ssl.xml。
jetty.port=80 jetty.dump.stop= etc/jetty-ssl.xml etc/jetty-https.xml
6)重啟Jetty,驗證https訪問是否正常。驗證
這幾篇文章你可能也喜歡:
- 在Nginx或Tengine服務器上安裝證書的操作步驟
- 在IIS服務器上安裝SSL證書的詳細操作步驟
- Tomcat如何部署SSL證書?CentOS系統Tomcat 8.5或9部署SSL證書的操作方法
- 如何在Apache服務器上安裝SSL證書?SSL證書安裝的操作步驟
本文由主機參考刊發,轉載請注明:Jetty服務器上如何安裝SSL證書?Jetty服務器安裝SSL證書的操作步驟 http://m.k2270.com/68493.html
主機參考

















評論前必須登錄!
注冊