Fix bugs in generating CA certs and in signing certificates.