CACert and MyOpenID both do this: they have a form that, when submitted, will cause the browser to generate a key and send the public part up to be signed, then deliver back down the signed certificate containing that public key which the browser binds up in its keystore and uses for authentication in the future. I know how to use SSLVerify and similar to verify the client cert once the user has it, and I know how to generate a CA and client certs normally using the openssl command line tools, but not how to do the browser interaction bit to generate the key etc.
I'm probably using Apache and Ruby/Rack or PHP if that helps :)