<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>pieroxy.nettomcat</title>
    <link>https://pieroxy.net/blog/tags/tomcat/</link>
    <description>tech, dev, web &amp; other stuff</description>
    <language>en</language>
    <copyright>Pieroxy</copyright>
    <pubDate>Thu, 25 Aug 2022 14:06:00 GMT</pubDate>
    <dc:creator>Pieroxy</dc:creator>
    <dc:date>2022-08-25T14:06:00Z</dc:date>
    <dc:language>en</dc:language>
    <dc:rights>Pieroxy</dc:rights>
    <image>
      <title>pieroxy.nettomcat</title>
      <url>https://pieroxy.net/blog/tags/tomcat/</url>
    </image>
    <item>
      <title>Tomcat, Java and https</title>
      <link>https://pieroxy.net/blog/2013/04/16/1366141020000.html</link>
      <content:encoded>&lt;p&gt;So I recently acquired a free https certificate from StartSSL. All well and good, this was fairly easy. Now, I have 4 files at my disposal:
&lt;div class="code"&gt;ca.pem
pk.mydomain.com
ssl.crt
sub.class1.server.ca.pem&lt;/div&gt;

&lt;p&gt;At that stage I'm fine. I'm about to configure &lt;span class="code"&gt;https&lt;/span&gt; and will go on with my life. As it turned out, things aren't exactly going to turn out that way.

&lt;p&gt;Tomcat needs a &lt;span class="code"&gt;keystore&lt;/span&gt;. None of those files will make the trick of course, but none of the stupid attempts I was about to try made it any more. It's not about just throwing the three certs in a keystore. Oh no, it's a bit more than that.

&lt;p&gt;As usual, &lt;a href="http://stackoverflow.com/questions/10323447/convert-certificate-in-pkcs12-formate-for-tomcat"&gt;Stackoverflow&lt;/a&gt; bootstrapped me in the right direction.

&lt;div class="code"&gt;openssl rsa -in pk.mydomain.com -out out/ssl.key
cat sub.class1.server.ca.pem ca.pem &gt; out/intcacerts.pem
openssl pkcs12 -export -in ssl.crt -inkey out/ssl.key -certfile out/intcacerts.pem -name "mydomain" -out out/keyandcerts.p12&lt;/div&gt;

And that's it. Now, in the &lt;span class="code"&gt;server.xml&lt;/span&gt; you would find the following:
&lt;div class="code"&gt;...
      keystoreFile="/path/to/my/keystore/file/keyandcerts.p12" 
      keystoreType="PKCS12" 
...&lt;/div&gt;
And that's all. If you have several domain names running on your Tomcat instance, you need a certificate that will accommodate them all, because to this day, Tomcat cannot use a different certificate for different hosts.</content:encoded>
      <category domain="https://pieroxy.net/blog/categories/java/">Java</category>
      <category domain="https://pieroxy.net/blog/tags/https/">https</category>
      <category domain="https://pieroxy.net/blog/tags/java/">java</category>
      <category domain="https://pieroxy.net/blog/tags/ssl/">ssl</category>
      <category domain="https://pieroxy.net/blog/tags/tomcat/">tomcat</category>
      <pubDate>Tue, 16 Apr 2013 19:37:00 GMT</pubDate>
      <guid isPermaLink="false">tag:pieroxy.net,2013-04-16:pieroxy.net/1366141020000</guid>
      <dc:date>2013-04-16T19:37:00Z</dc:date>
    </item>
  </channel>
</rss>

