httpstomcat需要產生認證

來源:互聯網
上載者:User

標籤:tps   exception   color   native   ble   secure   配置   file   thread   

一.  建立tomcat認證

  

這裡使用JDK內建的keytool工具來產生認證:

  

1. 在jdk的安裝目錄\bin\keytool.exe下開啟keytool.exe

  

  

2. 在命令列中輸入以下命令:

keytool -genkeypair -alias "tomcat" -keyalg "RSA" -keystore "g:\tomcat.keystore"

   

以上命令將生產一對非對稱金鑰和自我簽名的認證g:\tomcat.keystore

注意:"名字與姓氏"應該是網域名稱,輸成了姓名,和真正啟動並執行時候網域名稱不符,會出問題

這裡我輸入的密碼是123456,  網域名稱是以tomcat為例,  省市以西安陝西為例

  

二. 配置tomcat伺服器

  

 定位到tomcat伺服器的安裝目錄, 找到conf下的server.xml檔案

找到如下已經被注釋的代碼:

  

1 <!--
2 <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
3 maxThreads="150" scheme="https" secure="true"
4 clientAuth="false" sslProtocol="TLS" />
5 -->

  

去掉注釋,修改為:

  

1 <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
2 maxThreads="150" scheme="https" secure="true"
3 clientAuth="false" sslProtocol="TLS"
4 keystoreFile="g:\tomcat.keystore"
5 keys 

三. 啟動tomcat伺服器

在IE瀏覽器中輸入: https://對應的網域名稱(和產生的認證一致)

選擇繼續瀏覽此網站

  

到此為止就搞定了

  

  

以下為網路上其他人遇到的問題以及解決方案,可以參考:

  

遇到的問題:

我在配置的過程中問題,當我修改了server.xml的配置後,啟動tomcat報錯

1 org.apache.catalina.core.StandardService initInternal
2 嚴重: Failed to initialize connector [Connector[HTTP/1.1-443]]
3 org.apache.catalina.LifecycleException: Failed to initialize component [Connector[HTTP/1.1-443]]
4 at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106)
5 at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
6 at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
7 at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:814)
8 at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
9 at org.apache.catalina.startup.Catalina.load(Catalina.java:633)
10 at org.apache.catalina.startup.Catalina.load(Catalina.java:658)
11 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
12 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
13 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
14 at java.lang.reflect.Method.invoke(Method.java:606)
15 at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)
16 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)
17 Caused by: org.apache.catalina.LifecycleException: Protocol handler initialization failed
18 at org.apache.catalina.connector.Connector.initInternal(Connector.java:983)
19 at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
20 ... 12 more
21 Caused by: java.lang.Exception: Connector attribute SSLCertificateFile must be defined when using SSL with APR
22 at org.apache.tomcat.util.net.AprEndpoint.bind(AprEndpoint.java:507)
23 at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:610)
24 at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:429)
25 at org.apache.catalina.connector.Connector.initInternal(Connector.java:981)
26 ... 13 more

  

網上找了下,可以將protocol="HTTP/1.1"替換為protocol="org.apache.coyote.http11.Http11Protocol",問題可以得以解決

httpstomcat需要產生認證

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.