<?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>Obsolete Your Idols</title>
	<atom:link href="http://blog.manjusri.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.manjusri.org</link>
	<description>Book Reviews and Blather</description>
	<lastBuildDate>Sun, 29 Apr 2012 15:37:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Comparison Shopping for Postfix Puppet Modules</title>
		<link>http://blog.manjusri.org/2012/04/29/comparison-shopping-for-postfix-puppet-modules/</link>
		<comments>http://blog.manjusri.org/2012/04/29/comparison-shopping-for-postfix-puppet-modules/#comments</comments>
		<pubDate>Sun, 29 Apr 2012 15:37:03 +0000</pubDate>
		<dc:creator>binder</dc:creator>
				<category><![CDATA[Nerdery]]></category>

		<guid isPermaLink="false">http://blog.manjusri.org/?p=438</guid>
		<description><![CDATA[If you know anything about me, you know that I&#8217;m almost painfully lazy, to the point that I will put hours of effort into avoiding doing work. Case in point: I wanted to build myself a Postfix server or a hundred, using Puppet. Well, that&#8217;s probably pretty easy, just grab the Package type and alter [...]]]></description>
			<content:encoded><![CDATA[<p>If you know anything about me, you know that I&#8217;m almost painfully lazy, to the point that I will put hours of effort into avoiding doing work. Case in point: I wanted to build myself a <a href="http://www.postfix.org/">Postfix</a> server or a hundred, using <a href="http://puppetlabs.com/puppet/puppet-open-source/">Puppet</a>. Well, that&#8217;s probably pretty easy, just grab the Package type and alter the config files, then stash them in the catalog as File types, cut, print, that&#8217;s a wrap. But oh man, that&#8217;s like 30 minutes of work. How tedious. Can&#8217;t somebody else do it? SingTFW to the rescue.</p>
<p>Cursory searches turned up 5 public git repositories containing Puppet modules to manage Postfix. Success! But, too much success! How could I pick the right one? I had some rough idea of what I wanted the one I used to do but maybe I&#8217;d overlooked some important feature. I&#8217;d better compare them. To start us off, here&#8217;s the list in the order the search found them.</p>
<ul>
<li><a href="https://github.com/camptocamp/puppet-postfix">camptocamp on github</a></li>
<li><a href="https://github.com/example42/puppet-modules/tree/master/postfix">example42 on github</a></li>
<li><a href="https://github.com/ghoneycutt/puppet-postfix">ghoneycutt on github</a></li>
<li><a href="https://github.com/deck/puppet-postfix">deck on github</a></li>
<li><a href="https://labs.riseup.net/code/projects/shared-postfix">riseup-shared</a></li>
</ul>
<p>So I did what any self-respecting lazy person would, I fired off 5 clones in parallel and went to force  a machine to make me coffee.</p>
<p>Once everything was in place, I started doing tree and diff in various places to get a feel for how the repos were laid out, which features were visible in module names, which systems were supported. The very first thing I noticed is that the deck and riseup repos are virtually identical, and so I surmise lazily that the latter is built upon the former. This also meant that I can eliminate deck from consideration in favor of riseup. So now there were four.</p>
<p>But now it&#8217;s time to drink that coffee.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.manjusri.org/2012/04/29/comparison-shopping-for-postfix-puppet-modules/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Well is There Something Stupid I Could Do With Masterless Puppet?</title>
		<link>http://blog.manjusri.org/2012/04/28/well-is-there-something-stupid-i-could-do-with-masterless-puppet/</link>
		<comments>http://blog.manjusri.org/2012/04/28/well-is-there-something-stupid-i-could-do-with-masterless-puppet/#comments</comments>
		<pubDate>Sat, 28 Apr 2012 16:11:58 +0000</pubDate>
		<dc:creator>binder</dc:creator>
				<category><![CDATA[Nerdery]]></category>

		<guid isPermaLink="false">http://blog.manjusri.org/?p=428</guid>
		<description><![CDATA[Yes! Of course there is! Here&#8217;s the money shot, first, so if you&#8217;re just looking for copypasta, you can move on. node default { &#160;&#160;package { &#039;rubygems&#039;: &#160;&#160;&#160;&#160;ensure =&#62; installed, &#160;&#160;} &#160;&#160;exec { &#039;gem install rspec-puppet &#62; /tmp/rspec.out&#039;: &#160;&#160;&#160;&#160;path =&#62; &#039;/usr/bin&#039;, &#160;&#160;&#160;&#160;creates =&#62; &#039;/var/lib/gems/1.8/gems/rspec-puppet-0.1.3/&#039;, &#160;&#160;&#160;&#160;require =&#62; Package[&#039;rubygems&#039;], &#160;&#160;} } OK, so what&#8217;s that all about? [...]]]></description>
			<content:encoded><![CDATA[<p>Yes! Of course there is! Here&#8217;s the money shot, first, so if you&#8217;re just looking for copypasta, you can move on.
<p><pre><code><br />
node default {<br />
&nbsp;&nbsp;package { &#039;rubygems&#039;:<br />
&nbsp;&nbsp;&nbsp;&nbsp;ensure =&gt; installed,<br />
&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;exec { &#039;gem install rspec-puppet &gt; /tmp/rspec.out&#039;:<br />
&nbsp;&nbsp;&nbsp;&nbsp;path =&gt; &#039;/usr/bin&#039;,<br />
&nbsp;&nbsp;&nbsp;&nbsp;creates =&gt; &#039;/var/lib/gems/1.8/gems/rspec-puppet-0.1.3/&#039;,<br />
&nbsp;&nbsp;&nbsp;&nbsp;require =&gt; Package[&#039;rubygems&#039;],<br />
&nbsp;&nbsp;}<br />
}<br />
<br />
</code></pre></p>
<p>OK, so what&#8217;s that all about?<br />
<h3>What it does</h3>
<p>It installs the package named rubygems which, on at least some Debian-ish systems, provides the &#8216;gem&#8217; command, beloved of Rubyists and with which I&#8217;m attempting to become better acquainted THEN it runs a command to install the <a href="https://github.com/rodjek/rspec-puppet">rspec-puppet</a> gem, IF the system doesn&#8217;t already have version 0.1.3 of the gem installed in a ruby version 1.8 environment. It does these things if you put it onto a system which has puppet installed and execute the command &#8216;sudo puppet apply &lt;file&gt;&#8217; on newer puppet installs or just &#8216;sudo puppet &lt;file&gt;&#8217; on older puppet installs.</p>
<p>
Interestingly, this is the second version of this manifest. The first lacked the <strong>require</strong> attribute and so when I ran it on my test system, it failed to execute the gem install, first, and then installed the rubygems package. Puppet is tricky like that and if you require things happen in a certain order, you have to make that happen. You could consider that a strength or an annoyance; I didn&#8217;t think much about it until I saw a presentation by <a href="https://plus.google.com/113735330166395113694/posts">Jason Wright</a> at Puppetcamp 2010 where he talked about how his group had designed their Puppet manifests to run once and if a second run introduced a change, it was considered an error.</p>
<p><h3>Why do this?</h3>
<p>So continuing with my simplest thing iteration of using AWS, I thought I&#8217;d try to bootstrap up a masterless Puppet environment. Why? Well, because I have no idea what my environment will look like. At this point I should probably emphasize that all of this is for my own personal AWS stuff and while I do use Puppet at my dayjob and I do use AWS at my dayjob, my usage of both is quite a bit different, there.</p>
<p>
More specifically, we have carved out essentially a standard-if-evolving application stack and put infrastructure in place to support that but here I&#8217;m just sort of dabbling with ideas. One of those ideas is the idea of running Puppet without a Puppetmaster node or nodes.</p>
<p>
It used to be a somewhat heretical idea to do without a Puppetmaster, though I gather PuppetLabs now fully <a href="http://docs.puppetlabs.com/#part-one-serverless-puppet">embraces</a> the idea, which is good. While having a central Puppetmaster has some advantages (centralized source of truth, centralized reporting), it has (for me, in AWS) some disadvantages (requires a dedicated persistent node, requires managing The Cert Situation, potentially requires special scaling considerations). There are many many use cases where running a Puppetmaster is brilliant idea.<br />
But if you don&#8217;t run one, you trade that for needing to solve some things on your own.</p>
<p>
The problems I&#8217;m solving right now are &#8216;where does a node get its catalog&#8217; (my answer of the moment: github) and &#8216;how does the node know what manifests to apply&#8217; (maotm: a manual application via puppet agent invocations). Neither of these are yet well-solved by me, I&#8217;d say, but I&#8217;m bootstrapping to something which I suspect will look more like &#8216;catalogs live in S3, the nodes use s3fs to get them, instance tags are used to decide which manifests to apply&#8217;. But I think I&#8217;m on the right track by writing manifests which refer to node default, because now I don&#8217;t have to worry about updating if my instance identifier changes.</p>
<p>
Oh, and the whole point of this stupid manifest is that now I can spin up an instance to develop my Puppet catalog on and get ready to test my Puppet manifests. I haven&#8217;t quite convinced myself that I should write a test to test this manifest which sets up the ability to test a manifest (y0, d4wg) but doing so would have a sickly sweet kind of self-referentialism to it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.manjusri.org/2012/04/28/well-is-there-something-stupid-i-could-do-with-masterless-puppet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>So What&#8217;s the Stupidest Thing I Could Do With AWS?</title>
		<link>http://blog.manjusri.org/2012/04/26/so-whats-the-stupidest-thing-i-could-do-with-aws/</link>
		<comments>http://blog.manjusri.org/2012/04/26/so-whats-the-stupidest-thing-i-could-do-with-aws/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 23:34:34 +0000</pubDate>
		<dc:creator>binder</dc:creator>
				<category><![CDATA[Nerdery]]></category>

		<guid isPermaLink="false">http://blog.manjusri.org/?p=425</guid>
		<description><![CDATA[Oh, that&#8217;s easy! Roll your own AMIs! What I did: got an Amazon Web Services account; that was easy, because I&#8217;m a white dude in America went to the Ubuntu UEC page clicked on one of the (EBS!) images which took me to the AWS launch instances page went through all the clicky bits to [...]]]></description>
			<content:encoded><![CDATA[<p>Oh, that&#8217;s easy! Roll your own AMIs!</p>
<p>What I did:</p>
<ul>
<li>got an Amazon Web Services account; that was easy, because I&#8217;m a white dude in America</li>
<li>went to the <a href="http://uec-images.ubuntu.com/">Ubuntu UEC page</a></li>
<li>clicked on one of the (EBS!) images which took me to the AWS launch instances page</li>
<li>went through all the clicky bits to make sure that the instance would allow ssh traffic in the security group</li>
<li>logged into the instance, and sudo apt-get update &amp;&amp; sudo apt-get dist-upgrade&#8217;d it</li>
<li>installed puppet because puppet is fucking awesome</li>
<li>clicked on Create Image from the AWS instances webpage</li>
<li>waited for that to finish, then terminated the running instance</li>
<li>launched an instance from the AMI I&#8217;d made</li>
<li>logged into the instance and did sudo apt-get install git because, yes, git is fucking awesome</li>
<li>clicked on Create Image again</li>
<li>waited for that to finish, then terminated the running instance</li>
</ul>
<p>So now I&#8217;ve got an AMI for doing development for my personal projects. Which is not, at this time, a euphemism for pornography.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.manjusri.org/2012/04/26/so-whats-the-stupidest-thing-i-could-do-with-aws/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Didn&#8217;t You Used to Have a Blog?</title>
		<link>http://blog.manjusri.org/2012/04/23/didnt-you-used-to-have-a-blog/</link>
		<comments>http://blog.manjusri.org/2012/04/23/didnt-you-used-to-have-a-blog/#comments</comments>
		<pubDate>Mon, 23 Apr 2012 19:51:39 +0000</pubDate>
		<dc:creator>binder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.manjusri.org/?p=421</guid>
		<description><![CDATA[The simplest explanation is that I got too busy with work to write about work. Then I got too busy with outside of work to write about non-work. Then it became A Thing, that I&#8217;d gone so long without blogging. So that&#8217;s why I&#8217;m not blogging.]]></description>
			<content:encoded><![CDATA[<p>The simplest explanation is that I got too busy with work to write about work.</p>
<p>Then I got too busy with outside of work to write about non-work.</p>
<p>Then it became A Thing, that I&#8217;d gone so long without blogging.</p>
<p>So that&#8217;s why I&#8217;m not blogging.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.manjusri.org/2012/04/23/didnt-you-used-to-have-a-blog/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>NJC: Day 8</title>
		<link>http://blog.manjusri.org/2011/07/05/njc-day-8/</link>
		<comments>http://blog.manjusri.org/2011/07/05/njc-day-8/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 17:54:22 +0000</pubDate>
		<dc:creator>binder</dc:creator>
				<category><![CDATA[Nerdery]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[bacula]]></category>
		<category><![CDATA[changelog]]></category>
		<category><![CDATA[chef]]></category>
		<category><![CDATA[ebs]]></category>
		<category><![CDATA[knife]]></category>

		<guid isPermaLink="false">http://blog.manjusri.org/?p=415</guid>
		<description><![CDATA[This was the last day before a 3 day weekend and as is customary around these parts, not many people came in and the ones who did left early. I didn&#8217;t really achieve anything worth talking about, just researched some more ideas for my next few proposals. Specifically, I looked at AWS documentation about Elastic [...]]]></description>
			<content:encoded><![CDATA[<p>This was the last day before a 3 day weekend and as is customary around these parts, not many people came in and the ones who did left early. I didn&#8217;t really achieve anything worth talking about, just researched some more ideas for my next few proposals.</p>
<p>Specifically, I looked at AWS documentation about <a href="http://aws.amazon.com/ebs/">Elastic Block Storage</a>, I looked at new <a href="http://www.bacula.org/en/dev-manual/main/main/Current_State_Bacula.html">Bacula features</a>, I looked at <a href="http://wiki.opscode.com/display/chef/Home">Chef</a> and specifically <a href="http://wiki.opscode.com/display/chef/Knife">Knife</a>.</p>
<p>Then I went to drink with co-workers, former and present.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.manjusri.org/2011/07/05/njc-day-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NJC: Day 7</title>
		<link>http://blog.manjusri.org/2011/07/05/njc-day-7/</link>
		<comments>http://blog.manjusri.org/2011/07/05/njc-day-7/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 17:50:06 +0000</pubDate>
		<dc:creator>binder</dc:creator>
				<category><![CDATA[Nerdery]]></category>
		<category><![CDATA[changelog]]></category>

		<guid isPermaLink="false">http://blog.manjusri.org/?p=413</guid>
		<description><![CDATA[This day was my first day working from home at the new job, something I negotiated to get for myself. One day a week, I work from home. Unfortunately as today was the second attempt at releasing, and things took about as long as they do the first time you do something operational, this was [...]]]></description>
			<content:encoded><![CDATA[<p>This day was my first day working from home at the new job, something I negotiated to get for myself. One day a week, I work from home. Unfortunately as today was the second attempt at releasing, and things took about as long as they do the first time you do something operational, this was a 14 hour day of work for me. At least I didn&#8217;t need pants to do it.</p>
<p>Our proposed deploy process didn&#8217;t survive its encounter with the actual server environment but that doesn&#8217;t come as a surprise; it&#8217;s still very raw and will be refined a lot, soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.manjusri.org/2011/07/05/njc-day-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NJC: Day 6</title>
		<link>http://blog.manjusri.org/2011/07/05/njc-day-6/</link>
		<comments>http://blog.manjusri.org/2011/07/05/njc-day-6/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 17:46:47 +0000</pubDate>
		<dc:creator>binder</dc:creator>
				<category><![CDATA[Nerdery]]></category>
		<category><![CDATA[changelog]]></category>

		<guid isPermaLink="false">http://blog.manjusri.org/?p=411</guid>
		<description><![CDATA[I had hoped to WFH on this day but we were on track to release something important so I came in to the office. First order of the day was sharing the Windows virtualbox file with my co-workers so they could fire up IE and validate things work in that browser, too. That led in [...]]]></description>
			<content:encoded><![CDATA[<p>I had hoped to WFH on this day but we were on track to release something important so I came in to the office.</p>
<p>First order of the day was sharing the Windows virtualbox file with my co-workers so they could fire up IE and validate things work in that browser, too.</p>
<p>That led in to a playdate for something on the web, followed by a process meeting about deployment which turned into a pair programming / code review session using a laptop jacked into a projector. I recommend this if you have more than one developer in a meeting, use the projector to display their code as you talk about related topics.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.manjusri.org/2011/07/05/njc-day-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NJC: Day 5</title>
		<link>http://blog.manjusri.org/2011/07/05/njc-day-5/</link>
		<comments>http://blog.manjusri.org/2011/07/05/njc-day-5/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 17:43:33 +0000</pubDate>
		<dc:creator>binder</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[changelog]]></category>
		<category><![CDATA[der]]></category>
		<category><![CDATA[jboss]]></category>
		<category><![CDATA[keytool]]></category>
		<category><![CDATA[openssl]]></category>
		<category><![CDATA[pkcs8]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[virtualbox]]></category>

		<guid isPermaLink="false">http://blog.manjusri.org/?p=400</guid>
		<description><![CDATA[At this point, I&#8217;ve been doing the new job for a week and routines are forming. I started the morning using a company card to pay for SSL certificates and then spent the rest of the day making them work with JBoss and Apache. The Apache part was the easy part, as the certificates were [...]]]></description>
			<content:encoded><![CDATA[<p>At this point, I&#8217;ve been doing the new job for a week and routines are forming.</p>
<p>I started the morning using a company card to pay for SSL certificates and then spent the rest of the day making them work with JBoss and Apache. The Apache part was the easy part, as the certificates were already in the correct form. Using Subject Alternate Names with the wildcard certificate meant that I could secure a variety of systems using it, with varying depths of subdomains.</p>
<p>But JBoss was a problem and here&#8217;s why. All the examples I could find on the web gloss over using a real certificate. They assume that it&#8217;s good enough to show you the syntax for a self-signed certificate you generate using keytool. In my case, it wasn&#8217;t. The process for using a CA-signed certificate turned out to be very different.</p>
<p>So here&#8217;s the key thing to know if you try this craziness. Keytool is a vicious betrayer of hope and will quietly do the wrong thing if you don&#8217;t fully grok what it does/wants. You need to turn to something else, in this case, <a href="http://www.openssl.org/">openssl</a>. This command will take your private key and put it in a form keytool can use:</p>
<p><strong>openssl pkcs8 -topk8 -nocrypt -in /your/private/ssl.key -inform PEM -out /someplace/safe/key.der -outform DER</strong></p>
<p>Then this command will turn your SSL certificate into something keytool can use:</p>
<p><strong>openssl x509 -in /your/private/ssl.crt -inform PEM -out /someplace/safe/cert.der -outform DER</strong></p>
<p>Then you run those files through a program someone else wrote. Not entirely excited about it but I read the source and it didn&#8217;t seem too dire.</p>
<p>&nbsp;</p>
<p>import java.security.*;<br />
import java.io.IOException;<br />
import java.io.InputStream;<br />
import java.io.FileInputStream;<br />
import java.io.DataInputStream;<br />
import java.io.ByteArrayInputStream;<br />
import java.io.FileOutputStream;<br />
import java.security.spec.*;<br />
import java.security.cert.Certificate;<br />
import java.security.cert.CertificateFactory;<br />
import java.util.Collection;<br />
import java.util.Iterator;</p>
<p>/**<br />
* ImportKey.java<br />
*<br />
*</p>
<p>This class imports a key and a certificate into a keystore<br />
* (<code>$home/keystore.ImportKey</code>). If the keystore is<br />
* already present, it is simply deleted. Both the key and the<br />
* certificate file must be in <code>DER</code>-format. The key must be<br />
* encoded with <code>PKCS#8</code>-format. The certificate must be<br />
* encoded in <code>X.509</code>-format.</p>
<p>*<br />
*</p>
<p>Key format:</p>
<p>*</p>
<p><pre><code>openssl pkcs8 -topk8 -nocrypt -in YOUR.KEY -out YOUR.KEY.der<br />
* -outform der</code></pre></p>
<p>*</p>
<p>Format of the certificate:</p>
<p>*</p>
<p><pre><code>openssl x509 -in YOUR.CERT -out YOUR.CERT.der -outform<br />
* der</code></pre></p>
<p>*</p>
<p>Import key and certificate:</p>
<p>*</p>
<p><code>java comu.ImportKey YOUR.KEY.der YOUR.CERT.der</code><br />
*<br />
*</p>
<p><em>Caution:</em> the old <code>keystore.ImportKey</code>-file is<br />
* deleted and replaced with a keystore only containing <code>YOUR.KEY</code><br />
* and <code>YOUR.CERT</code>. The keystore and the key has no password;<br />
* they can be set by the <code>keytool -keypasswd</code>-command for setting<br />
* the key password, and the <code>keytool -storepasswd</code>-command to set<br />
* the keystore password.<br />
*</p>
<p>The key and the certificate is stored under the alias<br />
* <code>importkey</code>; to change this, use <code>keytool -keyclone</code>.<br />
*<br />
* Created: Fri Apr 13 18:15:07 2001<br />
* Updated: Fri Apr 19 11:03:00 2002<br />
*<br />
* @author Joachim Karrer, Jens Carlberg<br />
* @version 1.1<br />
**/<br />
public class ImportKey {</p>
<p>/**<br />
*</p>
<p>Creates an InputStream from a file, and fills it with the complete<br />
* file. Thus, available() on the returned InputStream will return the<br />
* full number of bytes the file contains</p>
<p>* @param fname The filename<br />
* @return The filled InputStream<br />
* @exception IOException, if the Streams couldn&#8217;t be created.<br />
**/<br />
private static InputStream fullStream ( String fname ) throws IOException {<br />
FileInputStream fis = new FileInputStream(fname);<br />
DataInputStream dis = new DataInputStream(fis);<br />
byte[] bytes = new byte[dis.available()];<br />
dis.readFully(bytes);<br />
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);<br />
return bais;<br />
}</p>
<p>/**<br />
*</p>
<p>Takes two file names for a key and the certificate for the key,<br />
* and imports those into a keystore. Optionally it takes an alias<br />
* for the key.<br />
*</p>
<p>The first argument is the filename for the key. The key should be<br />
* in PKCS8-format.<br />
*</p>
<p>The second argument is the filename for the certificate for the key.<br />
*</p>
<p>If a third argument is given it is used as the alias. If missing,<br />
* the key is imported with the alias importkey<br />
*</p>
<p>The name of the keystore file can be controlled by setting<br />
* the keystore property (java -Dkeystore=mykeystore). If no name<br />
* is given, the file is named <code>keystore.ImportKey</code><br />
* and placed in your home directory.<br />
* @param args [0] Name of the key file, [1] Name of the certificate file<br />
* [2] Alias for the key.<br />
**/<br />
public static void main ( String args[]) {</p>
<p>// change this if you want another password by default<br />
String keypass = &#8220;importkey&#8221;;</p>
<p>// change this if you want another alias by default<br />
String defaultalias = &#8220;importkey&#8221;;</p>
<p>// change this if you want another keystorefile by default<br />
String keystorename = System.getProperty(&#8220;keystore&#8221;);</p>
<p>if (keystorename == null)<br />
keystorename = System.getProperty(&#8220;user.home&#8221;)+<br />
System.getProperty(&#8220;file.separator&#8221;)+<br />
&#8220;keystore.ImportKey&#8221;; // especially this <img src='http://blog.manjusri.org/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>// parsing command line input<br />
String keyfile = &#8220;&#8221;;<br />
String certfile = &#8220;&#8221;;<br />
if (args.length &lt; 2 || args.length&gt;3) {<br />
System.out.println(&#8220;Usage: java comu.ImportKey keyfile certfile [alias]&#8220;);<br />
System.exit(0);<br />
} else {<br />
keyfile = args[0];<br />
certfile = args[1];<br />
if (args.length&gt;2)<br />
defaultalias = args[2];<br />
}</p>
<p>try {<br />
// initializing and clearing keystore<br />
KeyStore ks = KeyStore.getInstance(&#8220;JKS&#8221;, &#8220;SUN&#8221;);<br />
ks.load( null , keypass.toCharArray());<br />
System.out.println(&#8220;Using keystore-file : &#8220;+keystorename);<br />
ks.store(new FileOutputStream ( keystorename ),<br />
keypass.toCharArray());<br />
ks.load(new FileInputStream ( keystorename ),<br />
keypass.toCharArray());</p>
<p>// loading Key<br />
InputStream fl = fullStream (keyfile);<br />
byte[] key = new byte[fl.available()];<br />
KeyFactory kf = KeyFactory.getInstance(&#8220;RSA&#8221;);<br />
fl.read ( key, 0, fl.available() );<br />
fl.close();<br />
PKCS8EncodedKeySpec keysp = new PKCS8EncodedKeySpec ( key );<br />
PrivateKey ff = kf.generatePrivate (keysp);</p>
<p>// loading CertificateChain<br />
CertificateFactory cf = CertificateFactory.getInstance(&#8220;X.509&#8243;);<br />
InputStream certstream = fullStream (certfile);</p>
<p>Collection c = cf.generateCertificates(certstream) ;<br />
Certificate[] certs = new Certificate[c.toArray().length];</p>
<p>if (c.size() == 1) {<br />
certstream = fullStream (certfile);<br />
System.out.println(&#8220;One certificate, no chain.&#8221;);<br />
Certificate cert = cf.generateCertificate(certstream) ;<br />
certs[0] = cert;<br />
} else {<br />
System.out.println(&#8220;Certificate chain length: &#8220;+c.size());<br />
certs = (Certificate[])c.toArray();<br />
}</p>
<p>// storing keystore<br />
ks.setKeyEntry(defaultalias, ff,<br />
keypass.toCharArray(),<br />
certs );<br />
System.out.println (&#8220;Key and certificate stored.&#8221;);<br />
System.out.println (&#8220;Alias:&#8221;+defaultalias+&#8221; Password:&#8221;+keypass);<br />
ks.store(new FileOutputStream ( keystorename ),<br />
keypass.toCharArray());<br />
} catch (Exception ex) {<br />
ex.printStackTrace();<br />
}<br />
}</p>
<p>}// KeyStore</p>
<p>As found at <a href="http://www.agentbob.info/agentbob/79-AB.html">Agent Bob</a>.</p>
<p>Then the last remaining tricky bit is getting it out of the keystore this program creates and in to the one you intend to use. That could be as easy as just pointing jboss at this keystore but I made it harder and did this to copy from one keystore into another.</p>
<p><strong>keytool -importkeystore -srckeystore /the/keystore/made/by/importkey.java/keystore.ImportKey -srcstorepass importkey -destkeystore /the/one/you/use/jboss.keystore -deststorepass somethingclever -alias importkey -destalias production -srckeypass importkey -destkeypass somethingclever</strong></p>
<p>Then I edited /usr/local/java/jboss-VERSION/server/default/deploy/jboss-web.deployer/server.xml to modify the 8443 SSL connector they ship to do this:<br />
<pre><pre>&nbsp;&nbsp;&nbsp;&nbsp;&amp;lt;Connector port=&quot;443&quot; protocol=&quot;HTTP/1.1&quot; SSLEnabled=&quot;true&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxThreads=&quot;150&quot; scheme=&quot;https&quot; secure=&quot;true&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;address=&quot;${jboss.bind.address}&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;keystoreFile=&quot;/usr/local/java/jboss-VERSION/server/default/conf/ark.keystore&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;keyAlias=&quot;production&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;keystorePass=&quot;somethingclever&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clientAuth=&quot;false&quot; sslProtocol=&quot;TLS&quot; /&amp;gt;</pre></pre><br />
During this day I also got my hands on the 12G file which is a Windows virtualbox image in use by my nearest IT group. This doesn&#8217;t reveal some deep latent desire to be using Windows after all this time, this was me attempting to solve an issue for the people around me without taking on administration of Windows systems. It very nearly worked.</p>
<p>ETA: the key has its own password separate from the keystore. You can change it when you import that key into the new keystore, so I updated the command to reflect that.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.manjusri.org/2011/07/05/njc-day-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NJC: Day 4</title>
		<link>http://blog.manjusri.org/2011/07/05/njc-day-4/</link>
		<comments>http://blog.manjusri.org/2011/07/05/njc-day-4/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 16:45:23 +0000</pubDate>
		<dc:creator>binder</dc:creator>
				<category><![CDATA[Nerdery]]></category>
		<category><![CDATA[changelog]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://blog.manjusri.org/?p=398</guid>
		<description><![CDATA[This was my first Monday in the new office and so the focus was on all the orientation activity they only do on Mondays. I got my picture taken for a security badge (taken with a smart phone) and spent the day following up on orientation information as well as researching SSL certificate options before [...]]]></description>
			<content:encoded><![CDATA[<p>This was my first Monday in the new office and so the focus was on all the orientation activity they only do on Mondays. I got my picture taken for a security badge (taken with a smart phone) and spent the day following up on orientation information as well as researching SSL certificate options before proposing that the company pay for a wildcard SSL certificate for use in production environments and that we self-sign a different wildcard SSL certificate for use in development and testing environments.</p>
<p>Then I dug in to the documentation for how to use an SSL certificate with <a href="http://docs.jboss.org/jbossweb/3.0.x/ssl-howto.html">jboss</a>. That was more opaque than it needed to be and I&#8217;ll probably explain what I did in the next post.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.manjusri.org/2011/07/05/njc-day-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NJC: Day 3</title>
		<link>http://blog.manjusri.org/2011/06/25/njc-day-3/</link>
		<comments>http://blog.manjusri.org/2011/06/25/njc-day-3/#comments</comments>
		<pubDate>Sat, 25 Jun 2011 22:38:58 +0000</pubDate>
		<dc:creator>binder</dc:creator>
				<category><![CDATA[Nerdery]]></category>
		<category><![CDATA[changelog]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[pingdom]]></category>

		<guid isPermaLink="false">http://blog.manjusri.org/?p=386</guid>
		<description><![CDATA[I got an early start this day because I woke early for no real reason. So I headed into the office, had some breakfast there (grilled cheese with fried egg and coffee, thanks for asking) and got down to work. That meant installing Evernote for OS X so I could attach a PDF to a [...]]]></description>
			<content:encoded><![CDATA[<p>I got an early start this day because I woke early for no real reason. So I headed into the office, had some breakfast there (grilled cheese with fried egg and coffee, thanks for asking) and got down to work.</p>
<p>That meant installing<a href="http://www.evernote.com/about/download/mac.php"> Evernote for OS X</a> so I could attach a PDF to a note, then using the information I&#8217;d gathered there to write up a proposal concerning alerting. I am trying to be thorough in documenting what I do and why. I tried to capture my thinking, rationalize my decision, and foreshadow future developments. As part of the research for the writing I think I noticed something odd about <a href="http://www.pingdom.com/">Pingdom&#8217;s</a> pricing.</p>
<p>I&#8217;m probably misunderstanding something. But if the costs per check aren&#8217;t different at the Business plan level, and I don&#8217;t care about SMS notifies, what is my incentive to ever leave the Basic plan? My efficient frontier seems like it&#8217;s up and to the left and with a linear progression, it&#8217;s a Basic ballgame.</p>
<p><img src="https://spreadsheets.google.com/spreadsheet/oimg?key=0AmC_Diu6RQc9dEphcDE4bXhZSE9xZU5sc0ZwY3FEb0E&amp;oid=2&amp;zx=81ybniskmuc3" alt="" /></p>
<p>If the cost per check on the business plan is less, then the graph is wrong and there is a break-even point on the expense of checks. But <a href="http://www.pingdom.com/services/extraservices/">it sure doesn&#8217;t look like it.</a></p>
<p>I ran my proposal for additional monitoring past my boss and got his buy-in and then started deploying it. So that&#8217;s my first operational task which is not entirely reactive in nature; there had been an issue earlier with a system going away and no one noticing, but it wasn&#8217;t a production system and I was more interested in getting some kind of alerting going for those systems as they come online.</p>
<p>I fully expect to be iterating on the deployed monitoring solution, as it was a trade-off between results and costs (financial and my time/effort/brain) and there are arguably better solutions I didn&#8217;t feel like I could invest enough into at this point to get the most out of. It&#8217;s a starting point, an incremental improvement over what the company had in place before me.</p>
<p>This wasn&#8217;t quite a No Changes Friday (the only religious holiday I observe) but  it seemed worth it to push through that sabbath to get additional awareness of the environment. Arguably it didn&#8217;t impact anything production-related, beyond the tiny additional impact of the monitoring checks being done, which are all tickling network listening daemons.</p>
<p>Then I spent the rest of my day researching options for my next proposal, which will be SSL related.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.manjusri.org/2011/06/25/njc-day-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

