如何在GWT的Jetty中启用HTTPS?

时间:2011-06-16 11:17:48

标签: gwt https jetty

如何在GWT附带的Jetty中启用HTTPS?

2 个答案:

答案 0 :(得分:16)

gwt-dev.jar中有一个README-SSL.txt“hidden”。您可以找到最新版本on Github

特别是,将-server :ssl添加到Jetty的启动参数中,以使用localhost的默认自签名证书。

答案 1 :(得分:3)

嗨我认为这可以帮助那些人,我也使用GWT,我们被要求使用HTTPS。

基本上我们使用maven运行gwt,所以命令是这样的,以启用https。

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

这就是我使用jetty运行时插件的pom.xml部分的样子:run-war或jetty:run。

<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>