<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Simple Things</title>
	<atom:link href="http://hexeract.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://hexeract.wordpress.com</link>
	<description>Ink and Incapability</description>
	<lastBuildDate>Sat, 21 Jan 2012 19:25:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='hexeract.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Simple Things</title>
		<link>http://hexeract.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://hexeract.wordpress.com/osd.xml" title="Simple Things" />
	<atom:link rel='hub' href='http://hexeract.wordpress.com/?pushpress=hub'/>
		<item>
		<title>How to query software program vendor websites for the program version using ruby</title>
		<link>http://hexeract.wordpress.com/2011/07/17/how-to-query-software-program-vendor-websites-for-the-program-version-using-ruby/</link>
		<comments>http://hexeract.wordpress.com/2011/07/17/how-to-query-software-program-vendor-websites-for-the-program-version-using-ruby/#comments</comments>
		<pubDate>Sun, 17 Jul 2011 10:37:59 +0000</pubDate>
		<dc:creator>hexeract</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[mechanize]]></category>
		<category><![CDATA[nokogiri]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[sqlite3]]></category>
		<category><![CDATA[threads]]></category>

		<guid isPermaLink="false">http://hexeract.wordpress.com/?p=412</guid>
		<description><![CDATA[This is a followup to my previous article. The example in the previous post only checked three programs, but with more entries the overall execution time increases. With about 36 entries the execution time is around 20-40 seconds, depending on how fast the websites answer as each website is being accessed in sequence and waiting [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hexeract.wordpress.com&amp;blog=7317442&amp;post=412&amp;subd=hexeract&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is a followup to my previous <a href="http://hexeract.wordpress.com/2011/07/15/how-to-keep-up-with-new-versions-of-programs/" title="How to keep up with new versions of programs" target="_blank">article</a>.</p>
<p>The example in the previous post only checked three programs, but with more entries the overall execution time increases. With about 36 entries the execution time is around 20-40 seconds, depending on how fast the websites answer as each website is being accessed in sequence and waiting for each request to complete. This can and will add up. Additionally running the various unix commands in the pipe will not help towards overall efficiency. </p>
<p>So I decided to give it a try to make the script better and a hopefully a lot faster, especially when more websites are being accessed. My first thought was to try it with perl but parsing HTML with perl never quite worked for me when I wrote some test scripts. This may be due to me being inapt using HTML::TreeBuilder and/or XML::XPath. In any case, I was getting nowhere&#8230;</p>
<p>The second choice of a scripting language to use was ruby. As I already had done some website scraping using the ruby gems <a href="http://rubyforge.org/projects/mechanize/" title="RubyForge: Mechanize: Project Info" target="_blank">mechanize</a>, <a href="http://nokogiri.org/" title="An HTML, XML, SAX, &amp; Reader parser" target="_blank">nokogiri</a> and <a href="https://github.com/hpricot/hpricot/wiki" title="A Fast, Enjoyable HTML Parser for Ruby" target="_blank">hpricot</a> I thought trying to convert the shell script into a ruby script would be easy. Little did I know :)</p>
<p>Despite the fact it only accesses some websites and stores the version number (and the program name) in a sqlite3 database I hope it can serve as an example on how to use threads, mechanize, nokogiri, sqlite3 and how to pass code to a function.</p>
<p>Adding more checks does not increase the overall runtime too much. A test with 36 entries results in an overall runtime between two to five seconds. </p>
<p>Finding the actual xpath is not that easy, <a href="https://addons.mozilla.org/de/firefox/addon/firebug/" title="Firebug Firefox Addon" target="_blank">firebug</a> (Firefox) or the Developer Tools from Google Chrome can provide helpful hints but this is best tested in a small test script where also the version extraction ruby code can be written.</p>
<p>XPath and version extraction test script (example Metapad):<br />
<pre class="brush: ruby; auto-links: false; collapse: true; light: false; toolbar: true;">
#!/usr/bin/ruby

require 'rubygems'
require 'mechanize'
require 'nokogiri'

# exit upon control-c
trap(&quot;INT&quot;) { exit 1 } 

# site data
url   = 'http://liquidninja.com/metapad/download.html'
name  = 'MetaPad'
xpath = '/html/body/table/tr/td/table/tr/td/table/tr/td/table/tr/td'

# and access the site 
agent                  = Mechanize.new
agent.history.max_size = 0 
agent.user_agent_alias = 'Mac Safari'
agent.read_timeout     = 3 
page                   = agent.get(url)
found                  = page.search(xpath)

# this is to make it easier to just &quot;drop&quot; in the source code
# into the &quot;real script&quot;.
data = found

# display the &quot;elements&quot; we have hit to see if we are &quot;close&quot; with the xpath
    data.each do |node|
        puts &quot;-- NODE --&quot;
        puts node
    end
    puts &quot;--- OUTPUT ---&quot;

##### version extraction code 

versions = Array.new

data.each  do |node|
   versions.push(node.text) if node.to_s.include?('Version')
end

data = versions.first
data = data.strip.gsub!(/Version /, '');

#### version extraction code end
# assign the result back to 'result' 
result = data

# and print what we have
puts &quot;#{name}: #{result}&quot;
exit 0
</pre></p>
<p>&nbsp;<br />
The sqlite3 database table<br />
<pre class="brush: plain; auto-links: false; wrap-lines: false;">
sqlite&gt; .schema win32
CREATE TABLE win32 (program varchar(30) PRIMARY KEY, cver TEXT, pver TEXT, err INT default '0');
sqlite&gt; 
</pre><br />
Prior to writing to the database, an entry for the program must exist. This is an example on how to create an entry:<br />
<pre class="brush: plain; auto-links: false; wrap-lines: false;">
sqlite&gt; insert into win32 (program) values ('MetaPad');
sqlite&gt; select * from win32 where program='MetaPad';
MetaPad|||0
sqlite&gt; 
</pre></p>
<p>&nbsp;</p>
<p>And here is the final ruby script that checks three vendor websites and writes to the sqlite3 database:<br />
<pre class="brush: ruby; auto-links: false; wrap-lines: false;">
#!/usr/bin/ruby

require 'rubygems'
require 'mechanize'
require 'nokogiri'
require 'sqlite3'
require 'socket'

# exit upon control-c
trap(&quot;INT&quot;) { exit 1 }

# Setup the database
dbfile  = 'win32.db'
dbtable = 'win32'

# no database, no party
if not File.exists?(dbfile)
    puts &quot;Error, could not find database: #{dbfile}&quot;
    exit 10
end

# connect to the database
database = SQLite3::Database.new(dbfile)

# This hash will store the program name
# and its (scraped) version string
pv = Hash.new

# Using threads to make website scraping concurrent (and thus faster)
mythreads = Array.new

# This is the core routine of the script
# It takes three(!) arguments:
#  url:      What URL to access/get HTML from
#  xpath:    Using nokogiri, &quot;extract&quot; only a part of the HTML content
#  CODE:     The source code to parse the part of the HTML content to obtain
#            the version string

def getversion(url,xpath)
    # Set the default return value to ''
    result = ''

    # TCP connection check, host/service available?
    host   = url.split('/')
    host   = host[2]
    socket = TCPSocket.open(host, '80')

    # No socket, no access
    begin 
        socket = TCPSocket.open(host, '80')
    rescue  
        return result 
    end
    socket.close

    # This sets up a simple web client
    agent                  = Mechanize.new
    agent.history.max_size = 0
    agent.user_agent_alias = 'Mac Safari'
    agent.read_timeout     = 3
    agent.keep_alive       = false

    # Try and download the page
    # If something goes wrong, result will not have changed
    # and thus will be '' which will force the error counter to be increased
    begin
        page                   = agent.get url 
    rescue Mechanize::ResponseCodeError
        return result
    end

    # Parse the content using the xpath and nokogiri
    # which is accessed via the mechanize method .search 
    found                  = page.search xpath

    # If the array (of nokogiri) objects is not empty
    # execute the provided code block to obtain the version number
    if not found.empty?
    then
        result = yield found if block_given?
    end

    return result
end

###
# Metapad
t = Thread.new {
    url    = 'http://liquidninja.com/metapad/download.html'
    name   = 'MetaPad'
    xpath  = '/html/body/table/tr/td/table/tr/td/table/tr/td/table/tr/td'

# This is the call where url, xpath and some code is being supplied to the function
# The code passed uses the 'data' object which is the one also being 'returned'
# to the subroutine when the code block finishes

    result = getversion( url, xpath ) { |data|
                                        versions = Array.new
                                        data.each  do |node|
                                            versions.push(node.text) if node.to_s.include?('Version')
                                        end
                                        data = versions.first
                                        data = data.strip.gsub!(/Version /, '')
                                      }
    pv[&quot;#{name}&quot;] = result
}
mythreads.push(t)

###
# Pidgin
t = Thread.new {
    name   = 'Pidgin'
    url    = 'http://developer.pidgin.im/wiki/ChangeLog'
    xpath  = '/html/body/div/div/div/div/div/h2'

# Simpler code to extract the version number
    result = getversion( url, xpath ) { |data|
                                        data = data.first.text
                                        data = data.split(' ')
                                        data = data[1]
                                      }
    pv[&quot;#{name}&quot;] = result
}
mythreads.push(t)

###
# Adobe Flash Player
t = Thread.new {
    url    = 'http://www.adobe.com/de/software/flash/about/'
    name   = 'Adobe Flash Plugin'
    xpath  = '/html/body/div/div/div/div/table/tbody/tr/td'

# Simplest version :)
    result = getversion( url, xpath ) { |data| data = data[5].text }
    pv[&quot;#{name}&quot;] = result
}
mythreads.push(t)

#### More entries could go here :)

# Collect all threads and wait, if necessary
mythreads.each { |t| t.join }

# Create a string of database commands by
# looping through the 'pv' hash and create the individual update commands for sqlite3
# Each command is one element of the 'sql' array
sql = Array.new

pv.each do |p,v|
    sql.push(&quot;update #{dbtable} set cver = '#{v}' where program = '#{p}';&quot;)
end

# Convert the 'sql' array to one big string and batch execute
database.execute_batch( sql.join(&quot;\n&quot;) )

# The cver column for each program has been updated
# What is left is to query the database and print the results, if there are any

# reset error counter when cver has a value
database.execute(&quot;update #{dbtable} set err = 0 WHERE cver != ''&quot;)

# Report if the err counter is &gt;= 5
# Rhis means 5 consecutive runs went 'wrong' and requires a check as to # what/why.
# For example, if the vendor changes the output/structure of the website...
data = database.execute2(&quot;select program AS ProgramName,err AS ErrorRuns from win32 where err &gt;= 5&quot;)

# When executing the method execute2 the table header is also returned
# this means, the data array will always contain one element
# It will contain a second (and more) element(s) if actual data is returned
if data[1]
then
    data.each do |line|
        printf(&quot;%-20s %-15s\n&quot;, line[0], line[1])
    end
end

# Increase the error counter if current version is empty
database.execute(&quot;update win32 set err = err  + 1 WHERE cver=''&quot;)

# Compare the current version with previous version
# Do not compare when current version is empty
data =  database.execute2(&quot;select program AS ProgramName,pver AS OldVersion,cver AS CurrentVersion from win32 where ( cver != pver and cver != '')&quot;)

# see remark about execute2 above
if data[1]
then
    data.each do |line|
        printf(&quot;%-20s %-15s %-15s\n&quot;, line[0], line[1], line[2])
    end
end

# Set the previous version to the value of current version
# Do not set if the current version is empty
database.execute(&quot;update win32 SET pver = cver WHERE ( pver != cver and cver != '')&quot;)

exit 0
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hexeract.wordpress.com/412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hexeract.wordpress.com/412/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hexeract.wordpress.com/412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hexeract.wordpress.com/412/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hexeract.wordpress.com/412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hexeract.wordpress.com/412/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hexeract.wordpress.com/412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hexeract.wordpress.com/412/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hexeract.wordpress.com/412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hexeract.wordpress.com/412/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hexeract.wordpress.com/412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hexeract.wordpress.com/412/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hexeract.wordpress.com/412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hexeract.wordpress.com/412/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hexeract.wordpress.com&amp;blog=7317442&amp;post=412&amp;subd=hexeract&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hexeract.wordpress.com/2011/07/17/how-to-query-software-program-vendor-websites-for-the-program-version-using-ruby/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/290abdb318ff76c5a995d01d90e722fc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hexeract</media:title>
		</media:content>
	</item>
		<item>
		<title>How to keep up with new versions of programs</title>
		<link>http://hexeract.wordpress.com/2011/07/15/how-to-keep-up-with-new-versions-of-programs/</link>
		<comments>http://hexeract.wordpress.com/2011/07/15/how-to-keep-up-with-new-versions-of-programs/#comments</comments>
		<pubDate>Fri, 15 Jul 2011 15:40:38 +0000</pubDate>
		<dc:creator>hexeract</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[scraping]]></category>
		<category><![CDATA[sqlite3]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://hexeract.wordpress.com/?p=363</guid>
		<description><![CDATA[Keeping up with versions on your computer can be quite tedious, especially if those programs do not provide an auto-update feature. You could visit the vendor homepage for each software product you intend to keep up to date and check manually or use a program and hope it knows how to check for updates for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hexeract.wordpress.com&amp;blog=7317442&amp;post=363&amp;subd=hexeract&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Keeping up with versions on your computer can be quite tedious, especially if those programs do not provide an auto-update feature. You could visit the vendor homepage for each software product you intend to keep up to date and check manually or use a program and hope it knows how to check for updates for your software and last but not least visit a website regularly showing newly released/updated software.</p>
<p>Or you can build something yourself.</p>
<p>The example used here is awful and I am sure there a a million better ways to scrape websites (and as you will see later, can be easily replaced by something else) but should suffice to demonstrate on how to keep track of versions of programs you deem important.</p>
<p>Shown below is a method on how to scrape version information from vendor websites using curl and the usage of some unix commands to modify output from curl. If you want to know what each part in the pipe does just start with the initial command, look at the output and add a step at a time.</p>
<p>Example:<br />
<pre class="brush: plain; auto-links: false; gutter: false; wrap-lines: false;">
#!/bin/bash
echo -n &quot;Metapad: &quot;
curl -s -m 3 http://liquidninja.com/metapad/download.html | grep -A 5 &quot;Latest Release&quot;  | tail -1 | sed &quot;s/Version //g&quot;
echo -n &quot;Pidgin: &quot;
curl -s -m 3 http://developer.pidgin.im/wiki/ChangeLog | grep version | head -2 | tail -1 | perl -p -i -e &quot;s/&lt;.*?&gt;//g,&quot;  | awk '{ print $2 }'
echo -n &quot;Adobe Flash Plugin: &quot;
curl -s -m 3 http://www.adobe.com/de/software/flash/about/ | grep -A 2 &quot;Firefox, Mozilla, Netscape, Opera&quot;  | tail -1 | perl -p -i -e &quot;s/&lt;.*?&gt;//g,&quot; | awk '{ print $1 }'
</pre><br />
&nbsp;<br />
For the purpose of this article, the amount of checks is limited to three. Most likely you want to keep track of versions for more than three programs. Even if one assumes that you know the versions of all programs on your computer off by heart and you always install the latest software when available it is still easy to miss if an update is available just by looking at the script output. Especially with a lot more than just three&#8230;</p>
<p>In this scenario it would be helpful if the check could remember the version for each program from the previous run. Again, like with the example above on how to scrape websites, there are a million ways to keep track of such data, may it be a flat file (with either shell wizardry in-place editing/comparisons or using a revision control system) or a full blown Oracle Database 11g.</p>
<p>As I only want to store four values (program name, current version, previous version, error count) I decided to use sqlite3. This allows for a future migration to a proper database if the need arises.</p>
<p>Creating a database with sqlite3:<br />
<pre class="brush: plain; auto-links: false; gutter: false; toolbar: true; wrap-lines: false;">
$ sqlite3 win32.db &quot;create table win32 (program varchar(30) PRIMARY KEY, cver TEXT, pver TEXT, err INT default '0');&quot;
</pre><br />
&nbsp;<br />
Now, the database needs content. With just three examples, it would be faster to just manually enter the data.</p>
<p>Here are the individual commands:<br />
<pre class="brush: plain; auto-links: false; gutter: false; wrap-lines: false;">
$ sqlite3 win32.db &quot;insert into win32 (program, cver, pver) values ('Metapad','3,6','3,6');&quot;
$ sqlite3 win32.db &quot;insert into win32 (program, cver, pver) values ('Pidgin','2.9','2.9');&quot;
$ sqlite3 win32.db &quot;insert into win32 (program, cver, pver) values ('Adobe Flash Plugin','10.3.181.34','10.3.181.34');&quot;
</pre><br />
&nbsp;<br />
Checking if all data is in the database:<br />
<pre class="brush: plain; auto-links: false; gutter: false; wrap-lines: false;">
$ sqlite3 -header -column win32.db &quot;select * from win32;&quot;
program     cver        pver        err       
----------  ----------  ----------  ----------
Metapad     3,6         3,6         0         
Pidgin      2.9         2.9         0         
Adobe Flas  10.3.181.3  10.3.181.3  0  
</pre><br />
&nbsp;<br />
As seen, the data is available. But as the check script requires the functionality to write to the sqlite3 database this can be exploited to fill the database with initial values.</p>
<p>At first, delete the database and recreate it from scratch:<br />
<pre class="brush: plain; auto-links: false; gutter: false; wrap-lines: false;">
$ rm win32.db
$ sqlite3 win32.db &quot;create table win32 (program varchar(30) PRIMARY KEY, cver TEXT, pver TEXT, err INT default '0');&quot;
</pre><br />
&nbsp;<br />
For the script to write to the database, a function will do fine. The function takes the name and version as arguments, strips ^M and leading/trailing whitespaces from the version string and then writes the data to the database. The following shows the script that will fill the database with initial values.</p>
<p>Example:<br />
<pre class="brush: plain; auto-links: false; gutter: false; wrap-lines: false;">
#!/bin/bash

DATABASE=&quot;win32.db&quot;

if [ ! -e ${DATABASE} ]
then
    echo &quot;Error: Can not find sqlite3 Database to update/check&quot;
    exit 10
fi
function updatedb()
{
    name=$1
    version=$2
    sver=$(echo $version | tr -d '&#092;&#048;15' | sed 's/^[ \t]*//;s/[ \t]*$//')
    sqlite3 ${DATABASE} &quot;insert into win32 (program, cver, pver) values ('$name','$sver','$sver');&quot;
}

VERSION=$(curl -s -m 3 http://liquidninja.com/metapad/download.html | grep -A 5 &quot;Latest Release&quot;  | tail -1 | sed &quot;s/Version //g&quot;)
updatedb &quot;Metapad&quot; &quot;$VERSION&quot;

VERSION=$(curl -s -m 3 http://developer.pidgin.im/wiki/ChangeLog | grep version | head -2 | tail -1 | perl -p -i -e &quot;s/&lt;.*?&gt;//g,&quot;  | awk '{ print $2 }' )
updatedb &quot;Pidgin&quot; &quot;$VERSION&quot;

VERSION=$(curl -s -m 3 http://www.adobe.com/de/software/flash/about/ | grep -A 2 &quot;Firefox, Mozilla, Netscape, Opera&quot;  | tail -1 | perl -p -i -e &quot;s/&lt;.*?&gt;//g,&quot; | awk '{ print $1 }')
updatedb &quot;Adobe Flash Plugin&quot; &quot;$VERSION&quot;
</pre></p>
<p>Check if all the data has made it into the database as intended:</p>
<p><pre class="brush: plain; auto-links: false; gutter: false; wrap-lines: false;">
$ sqlite3 -header -column win32.db &quot;select * from win32;&quot;
program     cver        pver        err       
----------  ----------  ----------  ----------
Metapad     3,6         3,6         0         
Pidgin      2.9         2.9         0         
Adobe Flas  10.3.181.3  10.3.181.3  0 
</pre><br />
&nbsp;<br />
As you can see, the &#8220;Adobe Flash Player&#8221; string looks truncated.</p>
<p>Better check that:<br />
<pre class="brush: plain; auto-links: false; gutter: false; wrap-lines: false;">
$ sqlite3 -header -column win32.db &quot;select * from win32 where program like 'Adobe%';&quot;
program             cver         pver         err       
------------------  -----------  -----------  ----------
Adobe Flash Plugin  10.3.181.34  10.3.181.34  0
</pre><br />
&nbsp;<br />
Only the output was truncated, not the actual value.</p>
<p>As the database now has an intial state, the script requires some modifications so it can use and update the database. The function updatedb only requires a minor modification but at the end of the script there are some sqlite3 commands that check the version (and failed checks) and outputs program names where there is an update available.</p>
<p>This is what the complete script looks like:<br />
<pre class="brush: plain; auto-links: false; gutter: false; wrap-lines: false;">
#!/bin/bash

DATABASE=&quot;win32.db&quot;

if [ ! -e ${DATABASE} ]
then
    echo &quot;Error: Can not find sqlite3 Database to update/check&quot;
    exit 10
fi

function updatedb()
{
    name=$1
    version=$2
    sver=$(echo $version | tr -d '&#092;&#048;15' | sed 's/^[ \t]*//;s/[ \t]*$//')
    sqlite3 ${DATABASE} &quot;update win32 set cver='$sver' where program='$name';&quot;
}

VERSION=$(curl -s -m 3 http://liquidninja.com/metapad/download.html | grep -A 5 &quot;Latest Release&quot;  | tail -1 | sed &quot;s/Version //g&quot;)
updatedb &quot;Metapad&quot; &quot;$VERSION&quot;

VERSION=$(curl -s -m 3 http://developer.pidgin.im/wiki/ChangeLog | grep version | head -2 | tail -1 | perl -p -i -e &quot;s/&lt;.*?&gt;//g,&quot;  | awk '{ print $2 }' )
updatedb &quot;Pidgin&quot; &quot;$VERSION&quot;

VERSION=$(curl -s -m 3 http://www.adobe.com/de/software/flash/about/ | grep -A 2 &quot;Firefox, Mozilla, Netscape, Opera&quot;  | tail -1 | perl -p -i -e &quot;s/&lt;.*?&gt;//g,&quot; | awk '{ print $1 }')
updatedb &quot;Adobe Flash Plugin&quot; &quot;$VERSION&quot;


sqlite3                 ${DATABASE} &quot;update win32 set err = 0 WHERE cver != '';&quot;
sqlite3 -header -column ${DATABASE} &quot;select program AS ProgramName,err AS ErrorRuns from win32 where err &gt;= 5;&quot;
sqlite3                 ${DATABASE} &quot;update win32 set err = err  + 1 WHERE cver='';&quot;
sqlite3 -header -column ${DATABASE} &quot;select program AS ProgramName,pver AS OldVersion,cver AS CurrentVersion from win32 where ( cver != pver and cver != '');&quot;
sqlite3                 ${DATABASE} &quot;update win32 SET pver = cver WHERE ( pver != cver and cver != '' ); &quot;
</pre></p>
<p>The function updatedb was modified to update the current version column and five sqlite3 commands were added.</p>
<p>There is a fourth field in the database called &#8216;err&#8217; which is an error counter.  This is used to detect if the check for a version returns an empty string and for how many consecutive executions of the program.</p>
<p>Set the error counter to zero when the current version contains anything but an empty string.<br />
Display the program name and error counter if the error counter is equal or greater than five.<br />
Increase the error counter when the current version contains an empty string.<br />
Show the program name, the previous version and current version if current version is not an empty string.<br />
Set previous version to the value of current version when they are not equal and current version is not an empty string.</p>
<p>This should catch the problem when a check returns nothing. The check may be broken and needs attention/fixing.<br />
In any other case the version string may be some odd text which can be easily spotted when the current version and the previous version differ.</p>
<p>To check if the script works as intended, the pver value for one program can be modified using the following command:</p>
<p><pre class="brush: plain; auto-links: false; gutter: false; wrap-lines: false;">
$ sqlite3 win32.db &quot;update win32 set pver = 12345 where program like 'Adobe%';&quot;
$ sqlite3 -header -column win32.db &quot;select * from win32;&quot;
program     cver        pver        err       
----------  ----------  ----------  ----------
Metapad     3.6         3.6         0         
Pidgin      2.9.0       2.9.0       0         
Adobe Flas  10.3.181.3  12345       0  
</pre><br />
&nbsp;<br />
Running the script now should provide an output:<br />
<pre class="brush: plain; auto-links: false; gutter: false; wrap-lines: false;">
$ ./checkscript.sh
ProgramName         OldVersion  CurrentVersion
------------------  ----------  --------------
Adobe Flash Plugin  12345       10.3.181.34   
</pre><br />
&nbsp;<br />
Also, the OldVersion should be overwritten by the value of CurrentVersion:<br />
<pre class="brush: plain; auto-links: false; gutter: false; wrap-lines: false;">
$ sqlite3 -header -column win32.db &quot;select * from win32;&quot;
program     cver        pver        err       
----------  ----------  ----------  ----------
Metapad     3.6         3.6         0         
Pidgin      2.9.0       2.9.0       0         
Adobe Flas  10.3.181.3  10.3.181.3  0 
</pre><br />
&nbsp;<br />
A subsequent run of the script should not yield any output, unless the vendor updated the version in the time frame we ran the script again.  But does the error counter work as intended? Let&#8217;s find out!</p>
<p>Manually setting the current version to an empty string:<br />
<pre class="brush: plain; auto-links: false; gutter: false; wrap-lines: false;">
$ sqlite3 win32.db &quot;update win32 set cver='' where program = 'Metapad';&quot;
$ sqlite3 -header -column win32.db &quot;select * from win32;&quot;
program     cver        pver        err       
----------  ----------  ----------  ----------
Metapad                 3.6         0         
Pidgin      2.9.0       2.9.0       0         
Adobe Flas  10.3.181.3  10.3.181.3  0 
</pre></p>
<p>Rerunning the five sqlite3 commands and checking the result:<br />
<pre class="brush: plain; auto-links: false; gutter: false; wrap-lines: false;">
$ sqlite3                 win32.db &quot;update win32 set err = 0 WHERE cver != '';&quot;
$ sqlite3 -header -column win32.db &quot;select program AS ProgramName,err AS ErrorRuns from win32 where err &gt;= 5;&quot;
$ sqlite3                 win32.db &quot;update win32 set err = err  + 1 WHERE cver='';&quot;
$ sqlite3 -header -column win32.db &quot;select program AS ProgramName,pver AS OldVersion,cver AS CurrentVersion from win32 where ( cver != pver and cver != '');&quot;
$ sqlite3                 win32.db &quot;update win32 SET pver = cver WHERE ( pver != cver and cver != '' ); &quot;
$ sqlite3 -header -column win32.db &quot;select * from win32;&quot;
program     cver        pver        err       
----------  ----------  ----------  ----------
Metapad                 3.6         1         
Pidgin      2.9.0       2.9.0       0         
Adobe Flas  10.3.181.3  10.3.181.3  0  
</pre></p>
<p>Running the five sqlite3 commands another four times will bump the error counter to 5 and it should look like this:<br />
<pre class="brush: plain; auto-links: false; gutter: false; wrap-lines: false;">
sqlite3 -header -column win32.db &quot;select * from win32;&quot;
program     cver        pver        err       
----------  ----------  ----------  ----------
Metapad                 3.6         5         
Pidgin      2.9.0       2.9.0       0         
Adobe Flas  10.3.181.3  10.3.181.3  0 
</pre></p>
<p>The next time the 5 commands are run and current version is still an empty string, the following should happen:<br />
<pre class="brush: plain; auto-links: false; gutter: false; wrap-lines: false;">
$ sqlite3 -header -column win32.db &quot;select program AS ProgramName,err AS ErrorRuns from win32 where err &gt;= 5;&quot;
ProgramName  ErrorRuns 
-----------  ----------
Metapad      5         
$ sqlite3                 win32.db &quot;update win32 set err = err  + 1 WHERE cver='';&quot;
$ sqlite3 -header -column win32.db &quot;select program AS ProgramName,pver AS OldVersion,cver AS CurrentVersion from win32 where ( cver != pver and cver != '');&quot;
$ sqlite3                 win32.db &quot;update win32 SET pver = cver WHERE ( pver != cver and cver != '' ); &quot;
$ sqlite3 -header -column win32.db &quot;select * from win32;&quot;  
program     cver        pver        err       
----------  ----------  ----------  ----------
Metapad                 3.6         6         
Pidgin      2.9.0       2.9.0       0         
Adobe Flas  10.3.181.3  10.3.181.3  0      
</pre></p>
<p>The error counter did not get reset but the program was shown where obtaining the version has failed.<br />
Manually setting current version again to simulate that the next run of the version check for Metapad was successful:<br />
<pre class="brush: plain; auto-links: false; gutter: false; wrap-lines: false;">
$ sqlite3 win32.db &quot;update win32 set cver='3.6' where program = 'Metapad';&quot;
$ sqlite3 -header -column win32.db &quot;select * from win32;&quot;
program     cver        pver        err       
----------  ----------  ----------  ----------
Metapad     3.6         3.6         6         
Pidgin      2.9.0       2.9.0       0         
Adobe Flas  10.3.181.3  10.3.181.3  0         
$ sqlite3                 win32.db &quot;update win32 set err = 0 WHERE cver != '';&quot;
$ sqlite3 -header -column win32.db &quot;select program AS ProgramName,err AS ErrorRuns from win32 where err &gt;= 5;&quot;
$ sqlite3                 win32.db &quot;update win32 set err = err  + 1 WHERE cver='';&quot;
$ sqlite3 -header -column win32.db &quot;select program AS ProgramName,pver AS OldVersion,cver AS CurrentVersion from win32 where ( cver != pver and cver != '');&quot;
$ sqlite3                 win32.db &quot;update win32 SET pver = cver WHERE ( pver != cver and cver != '' ); &quot;
$ sqlite3 -header -column win32.db &quot;select * from win32;&quot;    
program     cver        pver        err       
----------  ----------  ----------  ----------
Metapad     3.6         3.6         0         
Pidgin      2.9.0       2.9.0       0         
Adobe Flas  10.3.181.3  10.3.181.3  0       
</pre></p>
<p>Now you should have a utility that can check for versions and tell you if new versions are available every time it is run.<br />
What you can do from there is left to the imagination of the reader :)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hexeract.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hexeract.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hexeract.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hexeract.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hexeract.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hexeract.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hexeract.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hexeract.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hexeract.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hexeract.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hexeract.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hexeract.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hexeract.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hexeract.wordpress.com/363/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hexeract.wordpress.com&amp;blog=7317442&amp;post=363&amp;subd=hexeract&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hexeract.wordpress.com/2011/07/15/how-to-keep-up-with-new-versions-of-programs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/290abdb318ff76c5a995d01d90e722fc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hexeract</media:title>
		</media:content>
	</item>
		<item>
		<title>Configure a WebDAV enabled webserver for multiple user folders and one shared folder</title>
		<link>http://hexeract.wordpress.com/2011/02/25/configure-a-webdav-enabled-webserver-for-multiple-user-folders-and-one-shared-folder/</link>
		<comments>http://hexeract.wordpress.com/2011/02/25/configure-a-webdav-enabled-webserver-for-multiple-user-folders-and-one-shared-folder/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 10:11:39 +0000</pubDate>
		<dc:creator>hexeract</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[WebDAV]]></category>
		<category><![CDATA[WebDAV apache multiple users folders configure]]></category>

		<guid isPermaLink="false">http://hexeract.wordpress.com/?p=269</guid>
		<description><![CDATA[I recently was requested to set up an apache webserver to provide WebDAV folders for multiple users with individual folders. Additionally, all users should be able to use a shared WebDAV folder. After some extensive research I was unable to find any good hints on how to actually do this. My first approach was to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hexeract.wordpress.com&amp;blog=7317442&amp;post=269&amp;subd=hexeract&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently was requested to set up an apache webserver to provide WebDAV folders for multiple users with individual folders. Additionally, all users should be able to use a shared WebDAV folder. After some extensive research I was unable to find any good hints on how to actually do this.</p>
<p>My first approach was to set up the WebDAV folders within the DocumentRoot and hence only one &lt;Directory&gt; configuration item was needed with multiple &lt;Location&gt; configuration items. At first sight, this seemed to provide what was requested.</p>
<p>After some testing it showed this approach had a major security issue:  If the user just accessed http://webdav.example.com and authenticated successfully, the user was able to see and write to all available folders. This is obviously an undesirable behaviour.</p>
<p>So I decided to move the WebDAV folders out of the DocumentRoot and providing an Alias, &lt;Directory&gt; and &lt;Location&gt;  configuration item for each folder and setting up access to that folder in the &lt;Location&gt; configuration item. Additionaly, this frees up the http://webdav.example.com which can provide further information on how to use the service.</p>
<p>And voilà, every user has his own WebDAV folder and can not see or access the folders of other users.</p>
<p>In the following example, three WebDAV folders are configured, one for each user and a shared folder for all users.</p>
<p><pre class="brush: plain;">
DAVLockDB /serv/webdav.example.org/auth/DAVLock
DAVMinTimeout 180 

NameVirtualHost 10.1.1.1
&lt;VirtualHost webdav.example.org&gt;

    ServerName  webdav.example.org
    ServerAdmin webmaster@example.org

    DocumentRoot /serv/webdav.example.org/htdocs/

    LogLevel warn 

    ErrorLog /serv/webdav.example.org/logs/error.log
    CustomLog /serv/webdav.example.org/logs/access.log combined

    # user1
    Alias /user1 /serv/webdav.example.org/webdav/user1

    &lt;Directory /serv/webdav.example.org/webdav/user1&gt;
        DAV             On
        AuthType        Basic 
        AuthName        &quot;My WebDav Directory&quot;
        AuthUserFile    /serv/webdav.example.org/auth/webdav.user
        Require         valid-user 
    &lt;/Directory&gt;

    &lt;Location /user1/&gt;
        Require     user user1
    &lt;/Location&gt;

    # user2
    Alias /user2 /serv/webdav.example.org/webdav/user2

    &lt;Directory /serv/webdav.example.org/webdav/user2&gt;
        DAV             On
        AuthType        Basic 
        AuthName        &quot;My WebDav Directory&quot;
        AuthUserFile    /serv/webdav.example.org/auth/webdav.user
        Require         valid-user 
    &lt;/Directory&gt;

    &lt;Location /user2/&gt;
        Require     user user2 
    &lt;/Location&gt;

    # transfer 
    Alias /transfer /serv/webdav.example.org/webdav/transfer

    &lt;Directory /serv/webdav.example.org/webdav/transfer&gt;
        DAV             On
        AuthType        Basic 
        AuthName        &quot;My WebDav Directory&quot;
        AuthUserFile    /serv/webdav.example.org/auth/webdav.user
        Require         valid-user 
    &lt;/Directory&gt;

    &lt;Location /transfer/&gt;
        Require    valid-user 
    &lt;/Location&gt;

&lt;/VirtualHost&gt;

</pre></p>
<p>If you want to allow the user to access his WebDAV directory using an Internet browser you can add the following lines to the corresponding &lt;Location&gt; configuration item.</p>
<p><pre class="brush: plain;">
 Options +Indexes
 IndexIgnore ..
 IndexOptions -IconsAreLinks NameWidth=* FancyIndexing SuppressLastModified FoldersFirst 
 IndexOrderDefault Ascending Name
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hexeract.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hexeract.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hexeract.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hexeract.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hexeract.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hexeract.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hexeract.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hexeract.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hexeract.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hexeract.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hexeract.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hexeract.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hexeract.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hexeract.wordpress.com/269/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hexeract.wordpress.com&amp;blog=7317442&amp;post=269&amp;subd=hexeract&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hexeract.wordpress.com/2011/02/25/configure-a-webdav-enabled-webserver-for-multiple-user-folders-and-one-shared-folder/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/290abdb318ff76c5a995d01d90e722fc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hexeract</media:title>
		</media:content>
	</item>
		<item>
		<title>Dealing with a Java keystore when keytool is not enough</title>
		<link>http://hexeract.wordpress.com/2010/11/16/dealing-with-a-java-keystore-when-keytool-is-not-enough/</link>
		<comments>http://hexeract.wordpress.com/2010/11/16/dealing-with-a-java-keystore-when-keytool-is-not-enough/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 11:51:18 +0000</pubDate>
		<dc:creator>hexeract</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[OpenSSL]]></category>
		<category><![CDATA[certificate]]></category>
		<category><![CDATA[extract]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[keystore]]></category>
		<category><![CDATA[keytool]]></category>
		<category><![CDATA[openssl]]></category>

		<guid isPermaLink="false">http://hexeract.wordpress.com/?p=234</guid>
		<description><![CDATA[It seems odd but the keytool program for handling a Java keystore is missing two rather obvious abilites. One missing ability is that keytool is unable to import a private key and the corresponding certificate to create a Java keystore from scratch. Another is to provide a way to extract a private key from the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hexeract.wordpress.com&amp;blog=7317442&amp;post=234&amp;subd=hexeract&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It seems odd but the keytool program for handling a Java keystore is missing two rather obvious abilites.<br />
One missing ability is that keytool is unable to import a private key and the corresponding certificate to create a Java keystore from scratch.<br />
Another is to provide a way to extract a private key from the Java keystore.</p>
<p>All you need is wget, a java compiler, OpenSSL and some spare time.</p>
<p>ImportKey.java was written by Joachim Karrer and Jens Carlberg<br />
ExportPriv.java was written by Alexey Zilber<br />
Base64Coder.java was written by Christian d&#8217;Heureuse, Inventec Informatik AG, Switzerland</p>
<ol>
<li>How to create a fresh Java keystore with a private key and a corresponding certificate<br />
<pre class="brush: plain;">
    $ openssl pkcs8 -topk8 -nocrypt -outform der -in somename.key.decrypted -out somename_pkcs8_key.der
    $ openssl x509 -inform PEM -outform DER -in somename.crt -out somename_certificate.der
    $ wget http://www.agentbob.info/agentbob/80/version/default/part/AttachmentData/data/ImportKey.java
    $ javac ImportKey.java
    $ java ImportKey somename_pkcs8_key.der somename_certificate.der
</pre><br />
This will create a keystore somewhere (for me, on a Windows machine, the location was:  C:\Documents and Settings\snowy\keystore.ImportKey ).
</li>
<li>How to extract a private key from the Java keystore<br />
<pre class="brush: plain;">
    $ keytool -export -alias mykey -keystore mystorage.jks -file exported-der.crt
    $ openssl x509 -out exported-pem.crt -outform pem -in exported-der.crt -inform der
    $ wget http://mark.foster.cc/pub/java/ExportPriv.java
    $ wget http://www.source-code.biz/base64coder/java/Base64Coder.java.txt 
    $ mv   Base64Coder.java.txt Base64Coder.java
    $ javac ExportPriv.java Base64Coder.java
    $ java ExportPriv mystorage.jks mykey changeit &gt; exported-pkcs8.key
</pre>
</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hexeract.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hexeract.wordpress.com/234/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hexeract.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hexeract.wordpress.com/234/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hexeract.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hexeract.wordpress.com/234/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hexeract.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hexeract.wordpress.com/234/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hexeract.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hexeract.wordpress.com/234/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hexeract.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hexeract.wordpress.com/234/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hexeract.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hexeract.wordpress.com/234/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hexeract.wordpress.com&amp;blog=7317442&amp;post=234&amp;subd=hexeract&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hexeract.wordpress.com/2010/11/16/dealing-with-a-java-keystore-when-keytool-is-not-enough/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/290abdb318ff76c5a995d01d90e722fc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hexeract</media:title>
		</media:content>
	</item>
		<item>
		<title>How to create a PKCS#12 which IKEYMAN will accept</title>
		<link>http://hexeract.wordpress.com/2010/11/07/how-to-create-a-pkcs12-which-ikeyman-will-accept/</link>
		<comments>http://hexeract.wordpress.com/2010/11/07/how-to-create-a-pkcs12-which-ikeyman-will-accept/#comments</comments>
		<pubDate>Sun, 07 Nov 2010 11:56:56 +0000</pubDate>
		<dc:creator>hexeract</dc:creator>
				<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://hexeract.wordpress.com/?p=214</guid>
		<description><![CDATA[This will apply if you did not use IKEYMAN to create the private key and the certificate request. Although IKEYMAN does allow to import other key storages (another key.db, Java keystore or PKCS#12) it is not as easy as it may seem. If you had your private key and certificate request in another key.db you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hexeract.wordpress.com&amp;blog=7317442&amp;post=214&amp;subd=hexeract&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This will apply if you did not use IKEYMAN to create the private key and the certificate request.<br />
Although IKEYMAN does allow to import other key storages (another key.db, Java keystore or PKCS#12) it is not as easy as it may seem.</p>
<p>If you had your private key and certificate request in another key.db you would use that and not have a need to import as you could simply use that key.db file.</p>
<p>The Java keystore is another matter and has even more problems than IKEYMAN. The keytool program does not allow the import of private keys.</p>
<p>For a simple import this may seem like a lot of effort and OpenSSL does provide to create a PKCS#12 so the obvious choice would be to just do that. Once a PKCS#12 is created IKEYMAN will happily read the file, request the container password and then fail&#8230;</p>
<p>The reason is that IKEYMAN does accept a PKCS#12 container but has some restraints towards the encryption algorithm used for the private key and certificate.</p>
<p>The working command for creating a successful PKCS#12 that IKEYMAN will accept is:</p>
<p><pre class="brush: plain;"> 
     $ openssl pkcs12 -export -name &quot;MyLabel&quot; -inkey  my-key.key -in my-cert.crt -out cert-and-key.p12 -keypbe PBE-SHA1-RC2-40
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hexeract.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hexeract.wordpress.com/214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hexeract.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hexeract.wordpress.com/214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hexeract.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hexeract.wordpress.com/214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hexeract.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hexeract.wordpress.com/214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hexeract.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hexeract.wordpress.com/214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hexeract.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hexeract.wordpress.com/214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hexeract.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hexeract.wordpress.com/214/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hexeract.wordpress.com&amp;blog=7317442&amp;post=214&amp;subd=hexeract&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hexeract.wordpress.com/2010/11/07/how-to-create-a-pkcs12-which-ikeyman-will-accept/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/290abdb318ff76c5a995d01d90e722fc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hexeract</media:title>
		</media:content>
	</item>
	</channel>
</rss>
