commonize the certificate creation boilerplate

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>