{"id":378,"date":"2020-05-02T11:33:14","date_gmt":"2020-05-02T09:33:14","guid":{"rendered":"http:\/\/blog.xoupix.fr\/?p=378"},"modified":"2020-05-02T11:33:16","modified_gmt":"2020-05-02T09:33:16","slug":"generate-self-signed-certificate-for-tomcat","status":"publish","type":"post","link":"https:\/\/blog.xoupix.fr\/index.php\/2020\/05\/02\/generate-self-signed-certificate-for-tomcat\/","title":{"rendered":"Generate self-signed certificate for Tomcat"},"content":{"rendered":"\n<p>Quick thread about generating a self-signed certificate for Apache Tomcat.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">Generating self-signed certificate<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">D:\\Tools\\Java\\jdk1.8.0_181\\bin\\keytool.exe -keysize 2048 -genkey -alias tomcat -keyalg RSA -keystore tomcat.keystore<\/pre>\n\n\n\n<p>You can add the option -validity &lt;number of days> to specify how many days your certificate should be valid. If not specified, the default validity period is 90 days.<\/p>\n\n\n\n<p>When creating it, you will be asked for keystore password, and organisation informations.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Adding the certificate to Apache Tomcat<\/h2>\n\n\n\n<p>Modify the server.xml Tomcat file, and uncomment the &lt;Connector \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 protocol=&#8221;org.apache.coyote.http11.Http11NioProtocol&#8221; node. On this specific node, you should change the following attributes:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>port <\/strong>attribute to set the https port to use, default is <strong>8443<\/strong><\/li><li><strong>SSLEnabled <\/strong>must be set to <strong>true<\/strong><\/li><li><strong>keystoreFile <\/strong>must point to <strong>your keystore file created previously<\/strong><\/li><li><strong>keystorePass <\/strong>must match <strong>the password your defined previously<\/strong><\/li><\/ul>\n\n\n\n<p>Save the file, and restart your Apache Tomcat instance.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Testing<\/h2>\n\n\n\n<p>Access the Apache Tomcat home page using the https:\/\/&lt;server ip>:&lt;defined https port>. You should be warned about the self-signed certificate.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"471\" src=\"https:\/\/blog.xoupix.fr\/wp-content\/uploads\/2020\/05\/image-1024x471.png\" alt=\"\" class=\"wp-image-380\" srcset=\"https:\/\/blog.xoupix.fr\/wp-content\/uploads\/2020\/05\/image-1024x471.png 1024w, https:\/\/blog.xoupix.fr\/wp-content\/uploads\/2020\/05\/image-300x138.png 300w, https:\/\/blog.xoupix.fr\/wp-content\/uploads\/2020\/05\/image-768x353.png 768w, https:\/\/blog.xoupix.fr\/wp-content\/uploads\/2020\/05\/image-500x230.png 500w, https:\/\/blog.xoupix.fr\/wp-content\/uploads\/2020\/05\/image.png 1242w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>You can go through this warning using the Advanced button and clicking on Accept the Risk and Continue<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"822\" height=\"470\" src=\"https:\/\/blog.xoupix.fr\/wp-content\/uploads\/2020\/05\/image-1.png\" alt=\"\" class=\"wp-image-381\" srcset=\"https:\/\/blog.xoupix.fr\/wp-content\/uploads\/2020\/05\/image-1.png 822w, https:\/\/blog.xoupix.fr\/wp-content\/uploads\/2020\/05\/image-1-300x172.png 300w, https:\/\/blog.xoupix.fr\/wp-content\/uploads\/2020\/05\/image-1-768x439.png 768w, https:\/\/blog.xoupix.fr\/wp-content\/uploads\/2020\/05\/image-1-500x286.png 500w\" sizes=\"auto, (max-width: 822px) 100vw, 822px\" \/><\/figure>\n\n\n\n<p>The Tomcat home page is displayed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"725\" height=\"321\" src=\"https:\/\/blog.xoupix.fr\/wp-content\/uploads\/2020\/05\/image-2.png\" alt=\"\" class=\"wp-image-382\" srcset=\"https:\/\/blog.xoupix.fr\/wp-content\/uploads\/2020\/05\/image-2.png 725w, https:\/\/blog.xoupix.fr\/wp-content\/uploads\/2020\/05\/image-2-300x133.png 300w, https:\/\/blog.xoupix.fr\/wp-content\/uploads\/2020\/05\/image-2-500x221.png 500w\" sizes=\"auto, (max-width: 725px) 100vw, 725px\" \/><\/figure>\n\n\n\n<p>The Tomcat server on secured port is operational.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Quick thread about generating a self-signed certificate for Apache Tomcat.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,11],"tags":[],"class_list":["post-378","post","type-post","status-publish","format-standard","hentry","category-apache-tomcat","category-ssl"],"_links":{"self":[{"href":"https:\/\/blog.xoupix.fr\/index.php\/wp-json\/wp\/v2\/posts\/378","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.xoupix.fr\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.xoupix.fr\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.xoupix.fr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.xoupix.fr\/index.php\/wp-json\/wp\/v2\/comments?post=378"}],"version-history":[{"count":2,"href":"https:\/\/blog.xoupix.fr\/index.php\/wp-json\/wp\/v2\/posts\/378\/revisions"}],"predecessor-version":[{"id":383,"href":"https:\/\/blog.xoupix.fr\/index.php\/wp-json\/wp\/v2\/posts\/378\/revisions\/383"}],"wp:attachment":[{"href":"https:\/\/blog.xoupix.fr\/index.php\/wp-json\/wp\/v2\/media?parent=378"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.xoupix.fr\/index.php\/wp-json\/wp\/v2\/categories?post=378"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.xoupix.fr\/index.php\/wp-json\/wp\/v2\/tags?post=378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}