Perl OpenSSL on OS X

Note to self for later reference: I regularly update my Dist::Zilla install on my computer (running OS X 10.9 Maverick). After the last update suddenly the [GitHub::Meta] plugin failed with the following error:

[GitHub::Meta] Getting GitHub repository info
[GitHub::Meta] Err: SSL connection failed for Client side SNI not supported for this openssl

The reason this fails is because the system-provided openssl < 1.0 does not support the client side SNI. Upgrading OpenSSL to a more recent version easily fixes this:

brew install openssl

Fixing SSL problems with Dist::Zilla and github

I’m using Dist::Zilla extensively to test/release the Perl code I write.

I had to fix a bug on one of the modules I wrote and I ran into this error when I tried ‘dist test’ on the freshly checked out repo:

[GitHub::Meta] Getting GitHub repository info
[GitHub::Meta] Err:  SSL connection failed for Client side SNI not supported for this openssl

After some searching I found that IO::Socket::SSL throws this error when it tries to use openssl releases from before the 1.0 release. I’m on OS X 10.9 so this makes sense as it comes with openssl v0.9.8.

Onto homebrew to install openssl, then link it so it appears in /usr/local/bin

$ which openssl
$ openssl version
OpenSSL 1.0.1g 7 Apr 2014

But alas, ‘dzil test’ is still not working.

Looking into the Dist::Zilla::Plugins::GitHub::Meta code I see this error originates from a HTTP::Tiny call. Now, how to tell HTTP::Tiny to use the recent openssl?

I did

cpanm IO::Socket::SSL
cpanm Net::SSLeay
cpanm Net::HTTP
cpanm HTTP::Tiny

And after the last module install all is working fine again.

I have no time to investigate this further currently, but maybe it is of use to somebody else when the same error pops up.

Ultracapacitor capacity verification over time

A few years ago I installed a wireless, self-powered light sensor in my garden to determine when it is time to close down our electric blinds. It uses ultracapacitors to store energy during the day to be able to continue transmitting sensor status at night.

I monitored the capacitor voltage to be able to track the performance of the ultracap over time. The question was how it would behave during cold winter nights and hot summer days, and also if and how much the capacity of the component would be influenced by aging.

The first months the system worked fine, the ultracap got charged by the solar panel when the sun was shining, and the sensor node would happily bridge the night until sunrise, with even some juice left in the ultracap (the capacitor voltage never went below 3V). Over the time of a few months, the voltage was dropping further and further every night. A sign that the capacity of the ultracap was decreasing, as I assumed that the power consumption of the electronics would not change (the electronics are mounted in a water/airtight enclosure and were not touched).

After a year, I decided to add a second ultracap to help bridging nights. This helped temporarily, but after a few months the system voltage reached the minimum working voltage (2.5V) again every night.

After three years and after posting a message on on the influence of aging on an ultracapacitor, I decided to dismantle the sensor node to actually measure the remaining capacitance of the ultracap.

Continue reading Ultracapacitor capacity verification over time

Plugwise xPL interface for v2 firmware

So, I needed a few more Plugwise Circles to automate some devices at home. I’m using the very cool Perl toolkit by Mark Hindess to create an xPL compliant interface towards the devices on an NSLU2. Problem: the interface I used was only compatible with firmware v1, and of course the new Circles ship with a newer (and incompatible) firmware. Time to upgrade!

Thanks to the preparatory work of Maarten Damen and Roheve I didn’t have to reverse engineer the protocol myself. Credits to you guys! I upgraded the existing xpl-plugwise code that was originally developed by Jfn and I have put it in a git repository. It is available here.

Continue reading Plugwise xPL interface for v2 firmware

Incremental backup script with daily delta

This script enables a ‘Time Machine alike’ backup of folders on a computer to a remote server. The script keeps daily snapshots by saving the deltas compared to the previous backup. The rest of the info is symlinked so you don’t end up using 7 times the required amount of disk space on the server.

I’ve been using this script quite some time to backup my Linux desktop to an NSLU2. I found it back during the spring clean of my archives and save it here for future reference.


# This script does personal backups to a rsync backup server. You will end up
# with a 7 day rotating incremental backup. The incrementals will go
# into subdirectories named after the day of the week, and the current
# full backup goes into a directory called "current"
# Credits:

# directory to backup
BDIR_LIST="/home /usr/share/jalbum"

# excludes file - this contains a wildcard pattern per line of files to exclude

# the name of the backup machine

# your password on the backup server
export RSYNC_PASSWORD=<insert_password_here>

# --exclude-from=$EXCLUDES  
BACKUPDIR=`date +%A`
OPTS="--force --ignore-errors --delete-excluded 
      --delete --backup --backup-dir=$BACKUPDIR -a --exclude-from=$EXCLUDES"

export PATH=$PATH:/bin:/usr/bin:/usr/local/bin

# the following line clears the last weeks incremental directory
[ -d $HOME/emptydir ] || mkdir $HOME/emptydir
echo "Clearing last weeks incremental directory..."
rsync -vv --delete -a $HOME/emptydir/ backup@$BSERVER::backup/$BACKUPDIR
rmdir $HOME/emptydir

# now the actual transfer
echo "Starting actual backup..."
for BDIR in $BDIR_LIST; do
	rsync -vv $OPTS $BDIR backup@$BSERVER::backup/current

echo "Backup completed!"

Easy Time Capsule repair

Ok, so the power supply of my Apple Time Capsule got fried due to a not-so-efficient cooling strategy of the designer. Basically the built-in power supply stops working and all of a sudden the Time Capsule does not power on any more.

Several fixes were already proposed, but they all focussed on replacing the built-in power supply. The problem with that is that the 3.5″ internal hard drive needs both a 12V and a 5V rail. So either you fix the original supply, you connect an ATX power supply or you take a 12V supply and build your own DCDC convertor to generate the 5V net from the 12V of the supply.

I was looking for a more simple solution and came up with this…

Continue reading Easy Time Capsule repair