How to enable HTTPS in GWT's Jetty?

后端 未结 2 1151
走了就别回头了
走了就别回头了 2021-02-04 10:09

How can I enable HTTPS in Jetty, which comes with GWT?

相关标签:
2条回答
  • 2021-02-04 10:12

    There's a README-SSL.txt "hidden" in the gwt-dev.jar. You can find the latest version on Github.

    In particular, add -server :ssl to the startup parameters of Jetty to use a default self-signed certificate for localhost.

    0 讨论(0)
  • 2021-02-04 10:24

    Hi I think this can help some people there, I also use GWT and we were required to use HTTPS.

    Basically we run gwt using maven, so the command is something like this to enable https.

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

    And this is how my pom.xml section of the plugin looks like when running using jetty:run-war or 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>
    
    0 讨论(0)
提交回复
热议问题