Fix crash in CreateCert

fixes #7862