<?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>Colabrativ, Inc. &#187; Apache</title>
	<atom:link href="http://www.colabrativ.com/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.colabrativ.com</link>
	<description>An Experiment Documentation and Electronic Notebook Provider</description>
	<lastBuildDate>Tue, 28 Oct 2014 04:44:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Creating Self-Signed Certificates for Google Web Toolkit Running on Apache HTTPD and Tomcat on Amazon Web Services EC2</title>
		<link>http://www.colabrativ.com/self-signed-certificates-gwt-applications-apache-http-tomcat/</link>
		<comments>http://www.colabrativ.com/self-signed-certificates-gwt-applications-apache-http-tomcat/#comments</comments>
		<pubDate>Mon, 27 Aug 2012 20:43:09 +0000</pubDate>
		<dc:creator>Marc Whitlow</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Amazon Web Services]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[Elastic Compute Cloud]]></category>
		<category><![CDATA[HTTP Server]]></category>
		<category><![CDATA[Tomcat]]></category>

		<guid isPermaLink="false">http://www.colabrativ.com/?p=527</guid>
		<description><![CDATA[Creating and installing a self-signed Secure Sockets Layer (SSL) certificate on a server should be a relatively simple task. However, most of the documentation relating to these tasks is confusing. Most of the confusion arises from the fact that there &#8230; <a href="http://www.colabrativ.com/self-signed-certificates-gwt-applications-apache-http-tomcat/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Creating and installing a self-signed <a target="_blank" href="http://en.wikipedia.org/wiki/Secure_Sockets_Layer">Secure Sockets Layer (SSL)</a> certificate on a server should be a relatively simple task.  However, most of the documentation relating to these tasks is confusing.  Most of the confusion arises from the fact that there are a multitude of different server configurations that utilize the SSL to complete secure transactions over the web.  In order not to add to this confusion, the following tutorial will refer to the following server configuration: </p>
<table style="border:0px solid white;">
<tr>
<td style="border:0px solid white;">Server:</td>
<td style="border:0px solid white;">64 bit Linux server running on <a target="_blank" href="http://aws.amazon.com/">Amazon Web Services</a> <a target="_blank" href="http://aws.amazon.com/ec2/">Elastic Compute Cloud (EC2)</a> server based on AMI ami-3bc9997e</td>
</tr>
<tr>
<td style="border:0px solid white;">Server&nbsp;Software:</td>
<td style="border:0px solid white;"><a target="_blank" href="http://httpd.apache.org/ABOUT_APACHE.html">Apache HTTP Server (HTTPD)</a> and <a target="_blank" href="http://tomcat.apache.org/">Apache Tomcat</a></td>
</tr>
<tr>
<td style="border:0px solid white;">Applications&nbsp;Type:</td>
<td style="border:0px solid white;"><a target="_blank" href="https://developers.google.com/web-toolkit/">Google Web Toolkit</a> and Java servlets</td>
</tr>
</table>
<p>In this post I will describe:</p>
<ol>
<li><a href="#create-keystore">Creation of self-signed SSL certificate in a Java keystore</a></li>
<li><a href="#add-keystore-to-tomcat">Adding keystore to Tomcat&#8217;s server.xml</a></li>
<li><a href="#extract-key-cert">Extracting the certificate and the key from the keystore</a></li>
<li><a href="#configure-ssl-conf">Configuring Apache Server (httpd) ssl.conf</a></li>
</ol>
<h3 id="create-keystore">Creation of self-signed SSL certificate</h3>
<p>Here we will use a <a target="_blank" href="http://docs.oracle.com/javase/6/docs/api/java/security/KeyStore.html">Java KeyStore</a> to supply Apache Tomcat the certificates we generate.  One of the limitations to this approach is that you must start by creating the KeyStore first.  SSL utilities such as <a target="_blank" href="http://docs.oracle.com/javase/1.4.2/docs/tooldocs/windows/keytool.html">Java keytool</a> and <a target="_blank" href="http://www.openssl.org/">OpenSSL</a> do not have the ability to create a keystore from an existing certificate and key.  In particular, there is no way to put the key in the keystore. </p>
<div class="codeBox">
<p>First we will create and open to the directory /etc/pki/tls/keystore.  The  <strong>keytool</strong> command that creates the keystore, we need to supply the following: </p>
<ul>
<li><strong>keystore</strong> file name: <span style="color: blue">demo.colabrativ.keystore</span></li>
<li><strong>alias</strong>: <span style="color: blue">tomcat</span></li>
<li><strong>keypass</strong>: <span style="color: blue">password</span></li>
<li><strong>storepass</strong>: <span style="color: blue">password</span></li>
</ul>
<p>In addition, we need to supply information on the website URL, when the keytool asks for &#8220;What is your first and last name?&#8221; and our institution information.  This information has been highlighted in green below in the example below.
</p>
<pre>$ sudo mkdir /etc/pki/tls/keystore
$ cd /etc/pki/tls/keystore
$ sudo keytool -genkey -alias tomcat -keypass <span style="color: blue">password</span> -keystore <span style="color: blue">demo.colabrativ.keystore</span> -storepass <span style="color: blue">password</span>
What is your first and last name?
  [Unknown]:  <span style="color: #080; font-weight:600;">demo.colabrativ.com</span>
What is the name of your organizational unit?
  [Unknown]:  <span style="color: #080; font-weight:600;">Developmemt</span>
What is the name of your organization?
  [Unknown]:  <span style="color: #080; font-weight:600;">Colabrativ, Inc.</span>
What is the name of your City or Locality?
  [Unknown]:  <span style="color: #080; font-weight:600;">El Sobrante</span>
What is the name of your State or Province?
  [Unknown]:  <span style="color: #080; font-weight:600;">California</span>
What is the two-letter country code for this unit?
  [Unknown]:  <span style="color: #080; font-weight:600;">US</span>
Is CN=demo.colabrativ.com, OU=Developmemt, O=Colabrativ, Inc., L=El Sobrante, ST=California, C=US correct?
  [no]:  <span style="color: #080; font-weight:600;">y</span>
</pre>
<p/>
<p>A useful command to check to keystore before preceeding is: </p>
<pre>$ sudo keytool -list -keystore <span style="color: blue">demo.colabrativ.keystore</span>
Enter keystore password: <span style="color: #080; font-weight:600;">password</span>

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

tomcat, Aug 27, 2012, PrivateKeyEntry,
Certificate fingerprint (MD5): 1A:2D:B5:C1:E9:1E:5C:A2:79:D3:8A:9B:A1:CE:14:72
</pre>
</div>
<h3 id="add-keystore-to-tomcat">Adding Keystore to Tomcat&#8217;s server.xml</h3>
<div class="codeBox">
<p>We configure Tomcat to support applications and services under the secure https protocol on port 8443.  We do this by editing the server.xml file in /etc/tomcat7.  We need to supply the keystore password in the 8443 Connector we enable.  I have saved the original server.xml, and only show the difference between the two files below. </p>
<pre>$ cd /etc/tomcat7
$ sudo cp -p server.xml server.xml.orig
$ sudo vi server.xml
$ sudo diff server.xml.orig server.xml
84,88c84,92
&lt;     &lt;!--
&lt;     &lt;Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
&lt;                maxThreads="150" scheme="https" secure="true"
&lt;                clientAuth="false" sslProtocol="TLS" /&#038;gt
&lt;     --&gt;
---
&gt;
&gt;     &lt;Connector port="8443"
&gt;                protocol="HTTP/1.1"
&gt;                SSLEnabled="true"
&gt;                maxThreads="150"
&gt;                scheme="https" secure="true"
&gt;                clientAuth="false" sslProtocol="TLS"
&gt;                keystoreFile="<span style="color: blue">/etc/pki/tls/keystore/demo.colabrativ.keystore</span>"
&gt;                keystorePass="<span style="color: blue">password</span>" /&gt;
</pre>
</div>
<h3 id="extract-key-cert">Extracting the Certificate and Key from the Keystore</a></h3>
<div class="codeBox">
<p>There are three steps in extracting the certificate and key from the keystore we created above:</p>
<ol>
<li>Use keytool to create an intermediate PKCS12 keystore.</li>
<li>Use OpenSSL to create a <a target="_blank" href="http://en.wikipedia.org/wiki/Privacy_Enhanced_Mail">Privacy-enhanced Electronic Mail (PEM)</a> formatted file containing the certificate and the key.
<li>Extract the certificate and key from the PEM file using a text editor.</li>
</ol>
<p>After the certificate and key have been prepared, they are moved the /etc/pki/tls/certs/, and /etc/pki/tls/private/ directories, respectively.
<p>The ASCII demo.colabrativ.pem file created during the preparation of this tutorial can be download at the bottom of this section. </p>
<pre>$ sudo keytool -importkeystore -srckeystore <span style="color: blue">demo.colabrativ.keystore</span> -destkeystore <span style="color: blue">demo.colabrativ.intermediate</span> -deststoretype PKCS12
Enter destination keystore password: <span style="color: #080; font-weight:600;">password</span>
Re-enter new password: <span style="color: #080; font-weight:600;">password</span>
Enter source keystore password: <span style="color: #080; font-weight:600;">password</span>
Entry for alias tomcat successfully imported.
Import command completed:  1 entries successfully imported, 0 entries failed or cancelled

$ sudo openssl pkcs12 -in <span style="color: blue">demo.colabrativ.intermediate</span> -out <span style="color: blue">demo..colabrativ.pem</span> -nodes
Enter Import Password: <span style="color: #080; font-weight:600;">password</span>
MAC verified OK

$ sudo cp demo.colabrativ.pem demo.colabrativ.key
$ sudo cp demo.colabrativ.pem demo.colabrativ.crt
$ sudo vi demo.colabrativ.key
$ sudo vi demo.colabrativ.crt

$ ls -lt
total 20
-rw-r--r-- 1 root root 1224 Aug 27 10:11 demo.colabrativ.crt
-rw-r--r-- 1 root root  509 Aug 27 10:11 demo.colabrativ.key
-rw-r--r-- 1 root root 2294 Aug 27 10:02 demo.colabrativ.pem
-rw-r--r-- 1 root root 1852 Aug 27 10:00 demo.colabrativ.intermediate
-rw-r--r-- 1 root root 1333 Aug 27 09:37 demo.colabrativ.keystore

$ sudo mv demo.colabrativ.crt /etc/pki/tls/certs/.
$ sudo mv demo.colabrativ.key /etc/pki/tls/private/.
</pre>
</p>
<p><strong>Download: <a target="_blank" href="http://www.colabrativ.com/files/ssl.conf">demo.colabrativ.pem</a></strong>
</div>
<h3 id="configure-ssl-conf">Configuring Apache Server (HTTPD) ssl.conf</a></h3>
<p>We will place all the SSL information for this server in the ssl.conf file in the /etc/httpd/conf.d directory.  The ssl.conf file is loaded into the Apache Server (HTTPD) from the command &#8220;Include conf.d/*.conf&#8221; in httpd.conf in directory /etc/httpd/conf.  You should check to be sure that this command is in your httpd.conf file.</p>
<div class="codeBox">
<p>We will place all the SSL information for this server in the ssl.conf file in the /etc/httpd/conf.d directory.  Shown below are the differences between the original ssl.conf file and the edited version.  It is a bit hard to tell where these changes were made from the file differences, so a copy of a demonstration ssl.conf file can be downloaded at the bottom of the section.</p>
<pre>$ cd /etc/httpd/conf.d
$ sudo cp –p ssl.conf ssl.conf.orig
$ sudo vi ssl.conf
$ sudo diff ssl.conf.orig ssl.conf
19a20,21
&gt; NameVirtualHost *:443
&gt;
74c76,77
&gt; &lt;VirtualHost _default_:443&gt;
---
&gt; #&lt;VirtualHost _default_:443&gt;
&gt; &lt;VirtualHost *:443&gt;
78a82
&gt; ServerName demo.colabrativ.com:443
85a90,100
&gt; #
&gt; # Proxy Server directives. Uncomment the following lines to
&gt; # enable the proxy server:
&gt; #
&gt; ProxyRequests Off
&gt; ProxyPass        /admin   https://demo.colabrativ.com:8443/admin
&gt; ProxyPass        /demoapp https://demo.colabrativ.com:8443/demoapp
&gt;
&gt; SSLProxyEngine on
&gt;
105c120,121
&lt; SSLCertificateFile /etc/pki/tls/certs/localhost.crt
---
&gt; #SSLCertificateFile /etc/pki/tls/certs/localhost.crt
&gt; SSLCertificateFile /etc/pki/tls/certs/demo.colabrativ.crt
112c128,129
&lt; SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
---
&gt; #SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
&gt; SSLCertificateKeyFile /etc/pki/tls/private/demo.colabrativ.key
</pre>
<p />
<p><strong>Download: <a target="_blank" href="http://www.colabrativ.com/files/ssl.conf">ssl.conf</a></strong></p>
</div>
<h3>Useful Resources</h3>
<ol>
<li>SSL Shopper&#8217;s <a target="_blank" href="http://www.sslshopper.com/article-most-common-java-keytool-keystore-commands.html">The Most Common Java Keytool Keystore Commands</a></li>
<li>SSL Shopper&#8217;s <a target="_blank" href="http://www.sslshopper.com/article-most-common-openssl-commands.html">The Most Common OpenSSL Commands</a></li>
<li>Wikipedia&#8217;s page on <a target="_blank" href="http://en.wikipedia.org/wiki/X.509">X.509</a>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.colabrativ.com/self-signed-certificates-gwt-applications-apache-http-tomcat/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
