Give consistent return value and add error code for duplicate certificates.