Exporting certificates from a Java keystore

There is a patently easy way to convert JKS keystores to PKCS12 certificate bundles (and vice versa). It’s a (poorly documented) keytool command that was introduced with JDK 6:

Convert JKS to P12

keytool -importkeystore -srckeystore keystore.jks -srcstoretype JKS -deststoretype PKCS12 -destkeystore keystore.p12

Convert P12 to JKS

keytool -importkeystore -srckeystore keystore.p12 -srcstoretype PKCS12 -deststoretype JKS -destkeystore keystore.jks

Borrowed from a blog post by tomas at EJBCA.

Dynamic IP script for Internode

WWW::Mechanize script for programmatically obtaining the current (dynamic) IPv4 and IPv6 addresses assigned to an Internode ADSL session:

#!/usr/bin/perl

use strict;
use warnings;
use WWW::Mechanize;

## Get current session data for our Internode session

my $mech = WWW::Mechanize->new();
my $user = ""; ## Enter Internode username
my $pass = ""; ## Enter Internode password

$mech->get('https://secure.internode.on.net/myinternode/sys0/login');
$mech->form_number(2);
$mech->set_fields(username => $user, password => $pass);
$mech->click('action');
$mech->follow_link (url_regex => qr/currentsessions/);

my $output = $mech->text();

## Locate IPv4 address in output
## ('IPv4:' on one side, '(dynamic)' on the other side)

my $v4_left = index ($output, "IPv4:") + 5;
my $v4_right = index ($output, "\(dynamic\)");

## Move IPv4 address in to its' own variable
## Remove new lines, leading and trailing spaces

my $ipv4 = substr $output, $v4_left, ($v4_right - $v4_left);
chomp $ipv4;
$ipv4 =~ s/^\s+//;
$ipv4 =~ s/\s+$//;

## Now do the same for the dynamically-assigned IPv6 address
## ('IPv6:' on one side, '(dynamic)' on the other side)

my $v6_left = index ($output, "IPv6:") + 5;
my $v6_right = rindex ($output, "\(dynamic\)");

## Move IPv6 address in to its' own variable
## Remove new lines, leading and trailing spaces

my $ipv6 = substr $output, $v6_left, ($v6_right - $v6_left);
chomp $ipv6;
$ipv6 =~ s/^\s+//;
$ipv6 =~ s/\s+$//;

## Print output

print "$ipv4\n";
print "$ipv6\n";

exit;

OS X Mountain Lion tips and tricks

General

sudo chflags nohidden ~/Library

Plug-ins

  • Flash installs as normal from adobe.com – use either Safari or Firefox to download
  • Java installs as normal from java.com – note that it is a 64-bit release and will not work with 32-bit software (e.g., Google Chrome)

Build environment

  • Xcode – download via the App Store – remember to install / enable the Command Line Tools (Xcode -> Preferences -> Downloads)
  • X11 – no longer included in OS X – install XQuartz instead

MacPorts

  • Installer available from the MacPorts site
  • Post installation config (definitely required for installing Wine):
echo export PATH=/opt/local/bin:/opt/local/sbin:\$PATH$'\n'export MANPATH=/opt/local/man:\$MANPATH | sudo tee -a /etc/profile
if [ `sysctl -n hw.cpu64bit_capable` -eq 1 ] ; then echo "+universal" | sudo tee -a /opt/local/etc/macports/variants.conf; else echo "not 64bit capable"; fi
sudo xcodebuild -license

Useful ports

sudo port install mtr
sudo port install nmap

Wine

sudo port install wine
sudo launchctl load -w /Library/LaunchDaemons/org.freedesktop.dbus-system.plist
launchctl load -w /Library/LaunchAgents/org.freedesktop.dbus-session.plist
sudo port install winetricks
winetricks vcrun2005sp1
winetricks ie7
winecfg

Xcode, MacPorts and Wine installation instructions adapted from David Baumgold’s site – has additional information and explanations