Added proper exceptions into the CertFactory class