Generate client keypairs before connecting, instead of after.

Part of issue #9.