cert_stuff: remove code duplication in the pkcs12 logic