Rewrite x509.certificate_managed to be easier to use
Rewrite x509.certificate_managed to be easier to use

The function now displays clearer error messages when a problem occurs
and informative messages when comparing an existing certificate.

test=True is now supported.

It fixes #52180, #39608, #41858 and others:

* Error messages from the x509 module calls are written directly to
the certificate file - fixed, the certificate file is only created
when the x509 module calls succeed.
* Certificates are created when no changes are required - fixed, the
comparison logic has been updated.

The `managed_private_key` option has been removed due to the added
complexity. The functionality can easily be replicated with an
additional call to `x509.private_key_managed`. According to the comment
at https://github.com/saltstack/salt/issues/39608#issuecomment-342346894
`managed_private_key` has not worked since at least v2016.11.2.

saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt