Report a readable error on a duplicate cert in ca app
authorMatt Caswell <matt@openssl.org>
Fri, 23 Feb 2018 18:28:47 +0000 (18:28 +0000)
committerMatt Caswell <matt@openssl.org>
Thu, 15 Mar 2018 12:51:34 +0000 (12:51 +0000)
commit2cedf79474ebc7bf910980f397decfaddec7122b
tree7ce101a07efe2c91705f3b0e3b7dad92c137f6a0
parentc845ff070d03052f10d9d183682388429cf4fd92
Report a readable error on a duplicate cert in ca app

Commit 87e8feca (16 years ago!) introduced a bug where if we are
attempting to insert a cert with a duplicate subject name, and
duplicate subject names are not allowed (which is the default),
then we get an unhelpful error message back (error number 2). Prior
to that commit we got a helpful error message which displayed details
of the conflicting entry in the database.

That commit was itself attempting to fix a bug with the noemailDN option
where we were setting the subject field in the database too early
(before extensions had made any amendments to it).

This PR moves the check for a conflicting Subject name until after all
changes to the Subject have been made by extensions etc.

This also, co-incidentally fixes the ca crashing bug described in issue
5109.

Fixes #5109

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5444)
apps/ca.c