Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cert checks in ipa-server-certinstall #50

Closed
wants to merge 1 commit into from

Conversation

flo-renaud
Copy link
Contributor

@flo-renaud flo-renaud commented Sep 2, 2016

When ipa-server-certinstall is called to install a new server certificate,
the prerequisite is that the certificate issuer must be already known by IPA.
This fix adds new checks to make sure that the tool exits before
modifying the target NSS database if it is not the case.
The fix consists in creating a temp NSS database with the CA certs from the
target NSS database + the new server cert and checking the new server cert
validity.

https://fedorahosted.org/freeipa/ticket/6263


# import all the CA certs from nssdb into the temp db
for nickname, flags in nssdb.list_certs():
if 'C' in flags:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CA certs don't have to have the C flag set. The proper check is if 'u' not in flags:.

@HonzaCholasta
Copy link
Contributor

NACK, see my inline comments above.

pkcs12_pin)
for nickname, flags in tempnssdb.list_certs():
if 'u' not in flags:
tempnssdb.delete_cert(nickname)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are multiple certs with the same nickname, delete_cert will only delete one of them. To delete them all, you have to:

while tempnssdb.has_nickname(nickname):
    tempnssdb.delete_cert(nickname)

@HonzaCholasta
Copy link
Contributor

More comments inline.

@flo-renaud flo-renaud force-pushed the fixservercert branch 2 times, most recently from 64d335e to 835eb95 Compare September 7, 2016 07:00
@flo-renaud
Copy link
Contributor Author

Bump for review

@HonzaCholasta
Copy link
Contributor

Functional ACK, but please don't use newlines in exception messages. If you want the original error on a separate line, you can use the logger to log it, but I think it would be preferable to use this format:

Peer's certificate issuer is not trusted ((SEC_ERROR_UNKNOWN_ISSUER) Peer's Certificate issuer is not recognized). Please run ipa-cacert-manage install and ipa-certupdate to install the CA certificate.

When ipa-server-certinstall is called to install a new server certificate,
the prerequisite is that the certificate issuer must be already known by IPA.
This fix adds new checks to make sure that the tool exits before
modifying the target NSS database if it is not the case.
The fix consists in creating a temp NSS database with the CA certs from the
target NSS database + the new server cert and checking the new server cert
validity.

https://fedorahosted.org/freeipa/ticket/6263
@HonzaCholasta HonzaCholasta added the ack Pull Request approved, can be merged label Sep 19, 2016
@HonzaCholasta
Copy link
Contributor

@HonzaCholasta HonzaCholasta added the pushed Pull Request has already been pushed label Sep 19, 2016
@flo-renaud flo-renaud deleted the fixservercert branch October 14, 2016 14:10
@HonzaCholasta
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ack Pull Request approved, can be merged pushed Pull Request has already been pushed
Projects
None yet
2 participants