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 support for the PKI v2 REST API + fall back #7587

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rcritten
Copy link
Contributor

This PR is mostly for verifying that fallover works when trying to contact a PKI API. It will use the v1/rest endpoints because v2 isn't available in Fedora yet. I will test with a temp commit at some point using the dogtag nightlies.

For now this is looking for regressions.

I haven't touch the KRA at all yet.

@rcritten rcritten added the WIP Work in progress - not ready yet for review label Oct 31, 2024
@rcritten rcritten force-pushed the pki_api_v2 branch 4 times, most recently from 6be468c to 7fa5271 Compare November 1, 2024 14:39
@rcritten rcritten added the re-run Trigger a new run of PR-CI label Nov 1, 2024
@freeipa-pr-ci freeipa-pr-ci removed the re-run Trigger a new run of PR-CI label Nov 1, 2024
@rcritten rcritten added the re-run Trigger a new run of PR-CI label Nov 1, 2024
@freeipa-pr-ci freeipa-pr-ci removed the re-run Trigger a new run of PR-CI label Nov 1, 2024
@rcritten rcritten added the re-run Trigger a new run of PR-CI label Nov 4, 2024
@freeipa-pr-ci freeipa-pr-ci removed the re-run Trigger a new run of PR-CI label Nov 4, 2024
@rcritten
Copy link
Contributor Author

rcritten commented Nov 4, 2024

The failed tests are due to a change in PKI related with "AttributeError: 'cryptography.hazmat.bindings._rust.x509.Certificate' object has no attribute 'not_valid_before_utc'"

This change was made due to deprecation warnings in python-cryptography. The PKI team is going to revert this change for now and will work on a fix that is forward and backwards compatible.

@rcritten
Copy link
Contributor Author

rcritten commented Nov 4, 2024

I did some additional testing including testing forwarding CA requests to a remote CA of a different version. The changes include:

  • catch exceptions in get_pki_version() so fallback works
  • added some debug logging to be able to see what is going on
  • strip the ca path resources to avoid whitespace issues
  • simplified the error handling in _ssldo to not duplicate the raise error code

Upstream PKI has fixed the UTC issue. Re-testing this patch.

@rcritten
Copy link
Contributor Author

rcritten commented Nov 4, 2024

There is a new bug in PKI causing the installation to fail.

@rcritten rcritten added the re-run Trigger a new run of PR-CI label Nov 4, 2024
@freeipa-pr-ci freeipa-pr-ci removed the re-run Trigger a new run of PR-CI label Nov 4, 2024
@rcritten rcritten added the re-run Trigger a new run of PR-CI label Nov 5, 2024
@freeipa-pr-ci freeipa-pr-ci removed the re-run Trigger a new run of PR-CI label Nov 5, 2024
fmarco76 and others added 3 commits November 5, 2024 10:41
PKI has a plan to re-implement REST APIs using different libraries
and supporting only JSON format. The new APIs have a different path,
/v2, and when ready the current implementation will be deprecated.

These APIs will not be back-ported to other branches and for the moment
the APIs will not be for external use but the CLI will be progressively
migrated to the new API endpoints so these have to be accessible.

For reference: https://github.com/dogtagpki/pki/wiki/CA-REST-API-v2

Related: https://pagure.io/freeipa/issue/9695
The v2 API avoids using VLV so will not have performance issues
with the 389 lmdb backend.

This adds a new configuration option, ca_url_base, which defines
the list of URI prefixes to try on the local or remote CA. On a
404 or 405 the code will failover to the next prefix until either
there is a successful invocation or they all fail.

The worst-case scenario is trying to retrieve a certificate that
does not exist. It will attempt on all prefixes until it fails.

It might be nice to have a global list of all CA's and their
versions so we can cache the prefix but IPA tries to avoid
global variables despite already no being thread-safe.

Fixes: https://pagure.io/freeipa/issue/9695

Signed-off-by: Rob Crittenden <[email protected]>
The existence of directory /root/.dogtag/pki-tomcat/ca was causing
TestExternalCAProfileScenarios to fail while testing the REST API
v2 change in https://pagure.io/freeipa/issue/9695

Related: https://pagure.io/freeipa/issue/8080
Related: https://pagure.io/freeipa/issue/9695

Signed-off-by: Rob Crittenden <[email protected]>
@rcritten rcritten added needs review Pull Request is waiting for a review ipa-next Mark as master (4.13) only and removed WIP Work in progress - not ready yet for review labels Nov 5, 2024
@rcritten rcritten changed the title WIP: try out a candidate PKI API v2 patch Add support for the PKI v2 REST API + fall back Nov 5, 2024
@rcritten rcritten added the re-run Trigger a new run of PR-CI label Nov 5, 2024
@freeipa-pr-ci freeipa-pr-ci removed the re-run Trigger a new run of PR-CI label Nov 5, 2024
@rcritten
Copy link
Contributor Author

rcritten commented Nov 6, 2024

Note that the KRA interface uses the pki-provided KRAClient class which is currently hardcoded at v1. I haven't yet investigated what to do about that such that it is forwards and backwards compatible.

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

Endi created an abstraction layer in PKI for the REST versions in PR dogtagpki/pki#4900
IPA makes direct API calls currently. I'll have to see how this new API works. Perhaps it will be similar to the KRA calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ipa-next Mark as master (4.13) only WIP Work in progress - not ready yet for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants