First and foremost, it should be noted that Maven Jetty plugin is not the same as Jetty server. Do not believe what documentation says.
After much suffering and using the scientific poke method it was derived that HTTP & HTTPS can be configured in Jetty plugin by inserting this code:
<connectors> <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> <port>80</port> <maxIdleTime>60000</maxIdleTime> </connector> <connector implementation="org.mortbay.jetty.security.SslSocketConnector"> <port>443</port> <maxIdleTime>60000</maxIdleTime> <keystore>keystore</keystore> <password>xxx</password> <keyPassword>xxx</keyPassword> </connector> </connectors>
in your webapp pom.xml file right under this
<artifactId>maven-jetty-plugin</artifactId> <version>6.1.10</version> <configuration>
As you can see there are two separate connectors for each port, so if you ever felt about having only one,
you can just delete the other connector configuration.
If you need a how-to on setting up SSL, here it is.
Bash commands are obviously for Linux keytool:
1. First a key needs to be generated and added to a keystore. Example:
keytool -keystore <keystore path and name> -alias <keyname> -genkey -keyalg RSA
The above command uses keytool to generate an RSA key with the name <keyname> for a specified keystore. It will prompt for keystore password (twice and will create a keystore if none exist at specified path), then for specific key data.
2. Second a certificate request needs to be generated. Example:
keytool -certreq -keystore <keystore path and name> -alias <keyname> -file <cretificate name and path>.csr
It is crucial that <keyname> and <keystore path and name> used are the same as in step #1
3. Open csr file and send the text from the inside to a certificate authority of your choice.
4. Upon receipt of an approved certificate, <name>.crt and a <root certificate>.crt
Make sure to acquire a root certificate from the authority you have selected. Some (ahem, godaddy, ahem) provide an intermediate certificate, which is not enough.
add both to the same <keystore path and name> using the following command:
keytool -import -alias <root> -keystore <keystore path and name> -file <root certificate>.crt
keytool -import -alias <keyname> -keystore <keystore path and name> -file <name>.crt
For root and approved certicate respectively.
5. Jetty was started/restarted.
Please, comment with questions if there are any.
No comments:
Post a Comment