<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SSL &#8211; My Shitty Code</title>
	<atom:link href="https://myshittycode.com/tag/ssl/feed/" rel="self" type="application/rss+xml" />
	<link>https://myshittycode.com</link>
	<description>Embracing the Messiness in Search of Epic Solutions</description>
	<lastBuildDate>Fri, 06 Jan 2023 17:01:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://myshittycode.com/wp-content/uploads/2022/04/cropped-icon-32x32.png</url>
	<title>SSL &#8211; My Shitty Code</title>
	<link>https://myshittycode.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">205304208</site>	<item>
		<title>Maven + Jetty: Enabling SSL on Jetty Maven Plugin</title>
		<link>https://myshittycode.com/2014/06/03/maven-jetty-enabling-ssl-on-jetty-maven-plugin/</link>
					<comments>https://myshittycode.com/2014/06/03/maven-jetty-enabling-ssl-on-jetty-maven-plugin/#respond</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Wed, 04 Jun 2014 02:05:19 +0000</pubDate>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[Jetty]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[SSL]]></category>
		<guid isPermaLink="false">http://myshittycode.com/?p=501</guid>

					<description><![CDATA[<p>PROBLEM In order to run our web application using HTTPS, we need to enable SSL first on Jetty. SOLUTION #1: Generating Certificate on the Fly One clean solution by @PascalThivent is to recreate the certificate whenever Jetty starts. Not to steal any credits from him, but here&#8217;s a slightly modified configuration using more recent plugin [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2014/06/03/maven-jetty-enabling-ssl-on-jetty-maven-plugin/">Maven + Jetty: Enabling SSL on Jetty Maven Plugin</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">PROBLEM</h2>



<p>In order to run our web application using HTTPS, we need to enable SSL first on Jetty.</p>



<h3 class="wp-block-heading">SOLUTION #1: Generating Certificate on the Fly</h3>



<p><a href="http://stackoverflow.com/questions/3794892/howto-use-https-ssl-with-maven-mortbay-jetty-plugin" target="_blank" rel="noopener">One clean solution by @PascalThivent</a> is to recreate the certificate whenever Jetty starts. Not to steal any credits from him, but here&#8217;s a slightly modified configuration using more recent plugin versions:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
&lt;plugin&gt;
    &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
    &lt;artifactId&gt;keytool-maven-plugin&lt;/artifactId&gt;
    &lt;version&gt;1.5&lt;/version&gt;
    &lt;executions&gt;
        &lt;execution&gt;
            &lt;phase&gt;generate-resources&lt;/phase&gt;
            &lt;id&gt;clean&lt;/id&gt;
            &lt;goals&gt;
                &lt;goal&gt;clean&lt;/goal&gt;
            &lt;/goals&gt;
        &lt;/execution&gt;
        &lt;execution&gt;
            &lt;phase&gt;generate-resources&lt;/phase&gt;
            &lt;id&gt;generateKeyPair&lt;/id&gt;
            &lt;goals&gt;
                &lt;goal&gt;generateKeyPair&lt;/goal&gt;
            &lt;/goals&gt;
        &lt;/execution&gt;
    &lt;/executions&gt;
    &lt;configuration&gt;
        &lt;keystore&gt;${project.build.directory}/jetty-ssl.keystore&lt;/keystore&gt;
        &lt;dname&gt;cn=localhost&lt;/dname&gt;
        &lt;!--Both `keypass` and `storepass` must be at least 6 characters long. --&gt;
        &lt;keypass&gt;jetty8&lt;/keypass&gt;
        &lt;storepass&gt;jetty8&lt;/storepass&gt;
        &lt;alias&gt;jetty8&lt;/alias&gt;
        &lt;keyalg&gt;RSA&lt;/keyalg&gt;
    &lt;/configuration&gt;
&lt;/plugin&gt;

&lt;plugin&gt;
    &lt;groupId&gt;org.mortbay.jetty&lt;/groupId&gt;
    &lt;artifactId&gt;jetty-maven-plugin&lt;/artifactId&gt;
    &lt;version&gt;8.1.14.v20131031&lt;/version&gt;
    ...
    &lt;configuration&gt;
        &lt;connectors&gt;
            &lt;connector implementation=&quot;org.eclipse.jetty.server.bio.SocketConnector&quot;&gt;
                &lt;port&gt;7777&lt;/port&gt;
            &lt;/connector&gt;
            &lt;connector implementation=&quot;org.eclipse.jetty.server.ssl.SslSocketConnector&quot;&gt;
                &lt;port&gt;7443&lt;/port&gt;
                &lt;keystore&gt;${project.build.directory}/jetty-ssl.keystore&lt;/keystore&gt;
                &lt;keyPassword&gt;jetty8&lt;/keyPassword&gt;
                &lt;password&gt;jetty8&lt;/password&gt;
            &lt;/connector&gt;
        &lt;/connectors&gt;
    &lt;/configuration&gt;
&lt;/plugin&gt;
</pre></div>


<p>In this case, the generated certificate is stored under the project&#8217;s build directory (&#8220;target&#8221; directory) every time we run <strong>mvn clean jetty:run</strong>. This is a great solution because it allows me to easily pass my project to my peers without the need to worry about the generated certificate.</p>



<p>However, a downside to this approach is because the certificate is regenerated again and again, my browser keeps prompting me to add an exception whenever I refresh the web link.</p>



<figure class="wp-block-image aligncenter"><img fetchpriority="high" decoding="async" width="602" height="426" src="https://myshittycode.com/wp-content/uploads/2014/06/screen-shot-2014-06-03-at-8-15-03-am-1.png?x45560" alt="" class="wp-image-505" srcset="https://myshittycode.com/wp-content/uploads/2014/06/screen-shot-2014-06-03-at-8-15-03-am-1.png 602w, https://myshittycode.com/wp-content/uploads/2014/06/screen-shot-2014-06-03-at-8-15-03-am-1-300x212.png 300w" sizes="(max-width: 602px) 100vw, 602px" /></figure>



<p>&#8230; and after adding the exception for like 5 times, it begins to get very annoying.</p>



<h3 class="wp-block-heading">SOLUTION #2: Generating Certificate Once and Reuse it</h3>



<p>Instead of regenerating the certificate again and again, I decided to generate the certificate that will last for 99999 days and store it under <strong>src/main/config</strong> directory.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; highlight: [6,13,29]; title: ; notranslate">
&lt;plugin&gt;
    &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
    &lt;artifactId&gt;keytool-maven-plugin&lt;/artifactId&gt;
    &lt;version&gt;1.5&lt;/version&gt;
    &lt;configuration&gt;
        &lt;keystore&gt;${project.basedir}/src/main/config/jetty-ssl.keystore&lt;/keystore&gt;
        &lt;dname&gt;cn=localhost&lt;/dname&gt;
        &lt;!--Both `keypass` and `storepass` must be at least 6 characters long. --&gt;
        &lt;keypass&gt;jetty8&lt;/keypass&gt;
        &lt;storepass&gt;jetty8&lt;/storepass&gt;
        &lt;alias&gt;jetty8&lt;/alias&gt;
        &lt;keyalg&gt;RSA&lt;/keyalg&gt;
        &lt;validity&gt;99999&lt;/validity&gt;
    &lt;/configuration&gt;
&lt;/plugin&gt;


&lt;plugin&gt;
    &lt;groupId&gt;org.mortbay.jetty&lt;/groupId&gt;
    &lt;artifactId&gt;jetty-maven-plugin&lt;/artifactId&gt;
    &lt;version&gt;8.1.14.v20131031&lt;/version&gt;
    ...
    &lt;configuration&gt;
        &lt;connectors&gt;
            &lt;connector implementation=&quot;org.eclipse.jetty.server.bio.SocketConnector&quot;&gt;
                &lt;port&gt;7777&lt;/port&gt;
            &lt;/connector&gt;
            &lt;connector implementation=&quot;org.eclipse.jetty.server.ssl.SslSocketConnector&quot;&gt;
                &lt;port&gt;7443&lt;/port&gt;
                &lt;keystore&gt;${project.basedir}/src/main/config/jetty-ssl.keystore&lt;/keystore&gt;
                &lt;keyPassword&gt;jetty8&lt;/keyPassword&gt;
                &lt;password&gt;jetty8&lt;/password&gt;
            &lt;/connector&gt;
        &lt;/connectors&gt;
    &lt;/configuration&gt;
&lt;/plugin&gt;
</pre></div>


<p>To generate (or regenerate) the certificate, run <strong>mvn keytool:clean keytool:generateKeyPair</strong>.</p>



<p>With this approach, I just need to add an exception ONCE in my browser regardless of the number of times I restart Jetty&#8230; or when I&#8217;m still actively working on this project after 99999 days.</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2014/06/03/maven-jetty-enabling-ssl-on-jetty-maven-plugin/">Maven + Jetty: Enabling SSL on Jetty Maven Plugin</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2014/06/03/maven-jetty-enabling-ssl-on-jetty-maven-plugin/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">501</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Lazy Loading (feed)
Database Caching using Disk

Served from: myshittycode.com @ 2026-02-20 10:53:25 by W3 Total Cache
-->