Fix certificate uploading.

This was still using parent improperly.

While here, make it so if related_id or related_md5 is set you must also
set related_type and vice versa. And if the related object can not be
found complain early.

This ensure that if relationships are specificed but can not be made we
will refuse to add the certificate.