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

Require an ipa-ca SAN on 3rd party certs if ACME is enabled #5119

Closed
wants to merge 3 commits into from

Conversation

rcritten
Copy link
Contributor

Require an ipa-ca SAN on 3rd party certs if ACME is enabled

ACME requires an ipa-ca SAN to have a fixed URL to connect to.
If the Apache certificate is replaced by a 3rd party cert then
it must provide this SAN otherwise it will break ACME.

Add a status option to ipa-acme-manage.

https://pagure.io/freeipa/issue/8498

Marking as ipa-next since I'm sure yet if ACME is going to be backported to ipa-4-8.

@rcritten rcritten added the ipa-next Mark as master (4.12) only label Sep 18, 2020
@rcritten rcritten force-pushed the issue_8498 branch 4 times, most recently from d3b68b2 to 837fef2 Compare September 18, 2020 20:12
Copy link
Contributor

@mrizwan93 mrizwan93 left a comment

Choose a reason for hiding this comment

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

Hello @rcritten ,
Please find comments inline.

@@ -93,6 +131,9 @@ def test_acme_service_not_yet_enabled(self):
['curl', '--fail', self.acme_server],
ok_returncode=22,
)
result = self.master.run_command(['ipa-acme-manage', 'status'])
assert result.returncode == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

This check can be removed., the return code for status command will be 0 anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I suppose any exception is sufficient in case something goes wrong.

@@ -111,6 +152,10 @@ def test_enable_acme_service(self):
else:
raise exc

result = self.master.run_command(['ipa-acme-manage', 'status'])
assert result.returncode == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

This check can be removed., the return code for status command will be 0 anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -252,3 +298,55 @@ def test_disable_acme_service(self):
['curl', '--fail', self.acme_server],
ok_returncode=22,
)
result = self.master.run_command(['ipa-acme-manage', 'status'])
assert result.returncode == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

This check can be removed., the return code for status command will be 0 anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

# Enable ACME which should fail since the Apache cert lacks the SAN
result = self.master.run_command(['ipa-acme-manage', 'enable'],
raiseonerr=False)
assert result.returncode == 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we make ipa-acme-manage enable command more robust in this case? cause return code 1 implies "CA is not installed on this server."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll look into a new return value for this and ipa-server-certinstall for invalid certificates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I'm going to adjust the return values in ipa-acme-manage 0 is success, 1 is an error, and 2 and 3 replace the current 1/2. ipa-server-certinstall only returns 0 == ok, 1 == error. Since ACME hasn't shipped in an official release IMHO it's fine to change this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with that change also.

"""Require ipa-ca SAN on replacement web certificates"""

result = self.master.run_command(['ipa-acme-manage', 'enable'])
assert result.returncode == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be removed as raiseonerr=True is set by default.

assert result.returncode == 1

result = self.master.run_command(['ipa-acme-manage', 'disable'])
assert result.returncode == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be removed as raiseonerr=True is set by default.

@rcritten rcritten added the re-run Trigger a new run of PR-CI label Sep 22, 2020
@freeipa-pr-ci freeipa-pr-ci removed the re-run Trigger a new run of PR-CI label Sep 22, 2020
Copy link
Contributor

@mrizwan93 mrizwan93 left a comment

Choose a reason for hiding this comment

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

Just a nitpick, else LGTM.

def test_third_party_certs(self):
"""Require ipa-ca SAN on replacement web certificates"""

result = self.master.run_command(['ipa-acme-manage', 'enable'])
Copy link
Contributor

Choose a reason for hiding this comment

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

variable result is not used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

result = self.certinstall()
assert result.returncode == 1

result = self.master.run_command(['ipa-acme-manage', 'disable'])
Copy link
Contributor

Choose a reason for hiding this comment

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

variable result is not used.

@rcritten
Copy link
Contributor Author

@frasertweedale do you have any opionions?

@rcritten rcritten added needs review Pull Request is waiting for a review WIP Work in progress - not ready yet for review and removed needs review Pull Request is waiting for a review labels Sep 28, 2020
@rcritten
Copy link
Contributor Author

rcritten commented Oct 5, 2020

Marking this as WIP as the status option will be dependent upon #5170

Copy link
Contributor

@frasertweedale frasertweedale left a comment

Choose a reason for hiding this comment

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

Haven't tested but the approach seems good to me.

ipaserver/install/cainstance.py Outdated Show resolved Hide resolved
# Enable ACME which should fail since the Apache cert lacks the SAN
result = self.master.run_command(['ipa-acme-manage', 'enable'],
raiseonerr=False)
assert result.returncode == 1
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with that change also.

@rcritten rcritten added needs review Pull Request is waiting for a review and removed WIP Work in progress - not ready yet for review labels Oct 13, 2020
@rcritten
Copy link
Contributor Author

Rebased on top of PR #5170 so we can potentially merge this at or near the same time.

@rcritten rcritten force-pushed the issue_8498 branch 3 times, most recently from ba6235b to ddb3520 Compare October 27, 2020 12:30
@freeipa-pr-ci freeipa-pr-ci added the needs rebase Pull Request cannot be automatically merged - needs to be rebased label Nov 2, 2020
ACME requires an ipa-ca SAN to have a fixed URL to connect to.
If the Apache certificate is replaced by a 3rd party cert then
it must provide this SAN otherwise it will break ACME.

https://pagure.io/freeipa/issue/8498

Signed-off-by: Rob Crittenden <rcritten@redhat.com>
Traditionally in IPA 0 = success, 1 = error and then
specific error messages follow from that. Shift the
ipa-acme-manage return codes for "not installed" and
"not a CA" up by one.

https://pagure.io/freeipa/issue/8498

Signed-off-by: Rob Crittenden <rcritten@redhat.com>
Test that:

1. With ACME enabled, SAN is required
2. With ACME disabled, SAN is not required

Also verify the ipa-acme-manage status command.

https://pagure.io/freeipa/issue/8498

Signed-off-by: Rob Crittenden <rcritten@redhat.com>
@rcritten rcritten added prioritized Pull Request has higher priority for PR-CI and removed needs rebase Pull Request cannot be automatically merged - needs to be rebased needs review Pull Request is waiting for a review labels Nov 2, 2020
@flo-renaud flo-renaud added the ack Pull Request approved, can be merged label Nov 2, 2020
@flo-renaud
Copy link
Contributor

ACK'ing based on @frasertweedale and @mrizwan93 comments

@rcritten rcritten added the pushed Pull Request has already been pushed label Nov 2, 2020
@rcritten
Copy link
Contributor Author

rcritten commented Nov 2, 2020

master:

  • 2768b0d Require an ipa-ca SAN on 3rd party certs if ACME is enabled
  • e0ff82c Change the return codes of ipa-acme-manage
  • c8f13cd ipatests: Add tests for requiring ipa-ca SAN when ACME is enabled

@rcritten rcritten closed this Nov 2, 2020
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 ipa-next Mark as master (4.12) only prioritized Pull Request has higher priority for PR-CI pushed Pull Request has already been pushed
Projects
None yet
5 participants