2011-06-16 49 views
11

如何在啓用GWT的Jetty中啓用HTTPS?如何在GWT的Jetty中啓用HTTPS?

+0

爲什麼在開發服務器上需要https? – 2011-06-16 12:56:38

+1

我們的項目中有一些安全功能,只能通過SSL訪問。因此,我也需要測試這個功能。 – Bob 2011-06-17 11:21:43

+0

你是否設法解決它? – mor222 2017-11-12 19:28:36

回答

15

在gwt-dev.jar中有一個「隱藏」的README-SSL.txt文件。你可以找到最新版本on Github

特別是,將-server :ssl添加到Jetty的啓動參數中以使用localhost的默認自簽名證書。

+0

任何想法,如果這種策略仍然有效?這是我能找到的唯一解決方案,但是如果我使用-server:ssl參數運行GWT,則會出現'無法加載服務器類'''。這看起來很奇怪,沒有-server:ssl參數都運行正常。 – Erix 2013-04-03 15:29:03

+0

請參閱:http://stackoverflow.com/questions/15791758/run-gwt-with-https-enabled關於此問題的擴展問題。 – Erix 2013-04-03 15:39:48

+0

此README-SSL.txt文件確實幫助我解決了嘗試配置自定義信任庫以用於內置服務器(Jetty)而不是本地主機的默認一個證書的問題。 – xRomZak 2015-11-12 11:19:54

3

嗨,我認爲這可以幫助那裏的一些人,我也使用GWT,我們被要求使用HTTPS。

基本上我們使用maven運行gwt,所以命令是這樣的,以啓用https。

gwt:debug -Dgwt.style=PRETTY -Dgwt.server=:ssl 

這是插件我的pom.xml部分看起來如何使用碼頭上運行時,如:運行戰爭或碼頭:運行。

<plugin> 
    <groupId>org.mortbay.jetty</groupId> 
    <artifactId>maven-jetty-plugin</artifactId> 
    <version>6.1.19</version> 
    <dependencies> 
     <dependency> 
      <groupId>commons-logging</groupId> 
      <artifactId>commons-logging</artifactId> 
      <version>1.1</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>servlet-api</artifactId> 
      <version>2.5</version> 
     </dependency> 
     <dependency> 
      <groupId>oracle-jdbc</groupId> 
      <artifactId>ojdbc</artifactId> 
      <version>14</version> 
     </dependency> 
    </dependencies> 
    <configuration> 
     <webApp>${project.build.directory}/${warName}.war</webApp> 
     <connectors> 
      <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> 
       <port>8080</port> 
       <maxIdleTime>60000</maxIdleTime> 
      </connector> 
      <connector implementation="org.mortbay.jetty.security.SslSocketConnector"> 
       <port>8443</port> 
       <maxIdleTime>60000</maxIdleTime> 
       <keystore>${project.build.directory}/jetty-ssl.keystore</keystore> 
       <password>jetty6</password> 
       <keyPassword>jetty6</keyPassword> 
      </connector> 
     </connectors> 
    </configuration> 
</plugin> 

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>keytool-maven-plugin</artifactId> 
    <executions> 
     <execution> 
      <phase>generate-resources</phase> 
      <id>clean</id> 
      <goals> 
       <goal>clean</goal> 
      </goals> 
     </execution> 
     <execution> 
      <phase>generate-resources</phase> 
      <id>genkey</id> 
      <goals> 
       <goal>genkey</goal> 
      </goals> 
     </execution> 
    </executions> 
    <configuration> 
     <keystore>${project.build.directory}/jetty-ssl.keystore</keystore> 
     <dname>cn=localhost</dname> 
     <keypass>jetty6</keypass> 
     <storepass>jetty6</storepass> 
     <alias>jetty6</alias> 
     <keyalg>RSA</keyalg> 
    </configuration> 
</plugin>