How to use openssl certificates with an "agent"

If you're like me then you don't like to leave private keys sitting around unencrypted on your filesystem. That means that any of those client certificates that you use for your fun gemini sites like bbs.geminispace.org or station.martinrue.com need to be encrypted.

If you're also like me and browse geminispace with command line tools this becomes a bit of a pain since having to type passwords in all the damn time is annoying.

How do you get around this? Use gpg for your private key encryption! You don't actually have to store the private keys *in* gpg, you just need to encrypt them like you would any sort of confidential data.

If you are using pxc and bash you can create and use a new identity like so:

The "process redirection" i.e. <() and >() mean you can pipe the data around purely within the shell so you never need to let it touch your disk.

bashrc functions for automation

If you'd like a bash function that will quickly switch between identities when using pxc, use switch_pxc() below. It makes an alias 'pxcc' that sets up pxc with the proper arguments.

You can use the below function to automatically generate new certificates that can be switched via switch_pxc. It accepts two arguments. The first is the certificate identity, and the optional second argument is the path to an existing private key. If no second argument is given then this function will generate a new key.

Enjoy!