#9331 Better handling of the command line and web UI cert search and/or list features
Closed: fixed by rcritten. Opened by rcritten.

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=2164349

When a user is browsing the WebUI and navigates to Authentication > Certificates, the webui performs a command equivalent to "ipa cert-find" without any size or time limit.

The IPA framework handles this operation in /ipaserver/plugins/cert.py, class cert_find, method execute()
https://github.com/freeipa/freeipa/blob/7d1d91fc86c49fcaaec05c772add13af36fc0209/ipaserver/plugins/cert.py#L1817

The execute method launches _ca_search, which in turn call ra.find()
https://github.com/freeipa/freeipa/blob/7d1d91fc86c49fcaaec05c772add13af36fc0209/ipaserver/plugins/cert.py#L1701

This method is defined in ipaserver/plugins/dogtag.py, class ra
https://github.com/freeipa/freeipa/blob/7d1d91fc86c49fcaaec05c772add13af36fc0209/ipaserver/plugins/dogtag.py#L1727

The method is doing an http request to PKI: POST /ca/rest/certs/search?size=2147483647
(the size is the default one, 0x7fffffff, used because no options.sizelimit was provided)
https://github.com/freeipa/freeipa/blob/7d1d91fc86c49fcaaec05c772add13af36fc0209/ipaserver/plugins/dogtag.py#L1828

Note: even if the user defines a sizelimit with ipa cert-find --sizelimit=xx, the limit passed to PKI is the default one 0x7fffffff. The limit is not forwarded from IPA framework to PKI.

The limit is only used when all the certs have been retrieved in order to truncate the returned entries:
https://github.com/freeipa/freeipa/blob/master/ipaserver/plugins/cert.py#L1917

    if (len(result) > sizelimit > 0):
        if not truncated:
            self.add_message(messages.SearchResultTruncated(
                    reason=errors.SizeLimitExceeded()))
        result = result[:sizelimit]
        truncated = True

On PKI side:
PKI server seems to properly honor the size parameter. If it receives POST /ca/rest/certs/search?size=0x00000001 it sends only the requested number of certificates, ie one.

In summary:
- IPA framework should be enhanced and make a better use of the size limit provided through ipa cert-find --sizelimit=xxx
- When no sizelimit is provided, the best would be to do a paged size when querying PKI. Not sure if PKI implements this functionality.


Metadata Update from @rcritten:
- Custom field rhbz adjusted to https://bugzilla.redhat.com/show_bug.cgi?id=2164349

PR https://github.com/freeipa/freeipa/pull/6698

master:

  • 2b2f10c2eb7f3b796c68771bc8cbf5dbaa646481 Enforce sizelimit in cert-find
  • 191880bc9f77c3e8a3cecc82e6eea33ab5ad03e4 Use the OpenSSL certificate parser in cert-find

ipa-4-9:

  • 6e04c4959bf1ebdc0a9d1cb24969bec278191438 Enforce sizelimit in cert-find
  • f54a55a1b4636391b443368e318176ea79d5ffc5 Use the OpenSSL certificate parser in cert-find

ipa-4-10:

  • e2576670e692117c11987118abd5e9381bb90b1f Enforce sizelimit in cert-find
  • 50dd79d1a35549034bc281fbdffea4399baed3c7 Use the OpenSSL certificate parser in cert-find

Metadata Update from @rcritten:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

master:

  • 1f30cc65276a532e7288217f216b72a2b0628c8f cert_find: fix call with --all

ipa-4-9:

  • 59cab232a0dcc210972dcfb43cb77df468e377ad cert_find: fix call with --all

ipa-4-10:

  • 918b6e011795ba4854d178d18c86ad54f3cf75ab cert_find: fix call with --all

Metadata Update from @rcritten:
- Custom field changelog adjusted to cert-find performance was improved dramatically when a large number of certificates are returned by changing the method IPA uses internally to parse results from the CA.

master:

  • 2a605c5d07906e157e79458724be098aab28cc7c Revert "Use the OpenSSL certificate parser in cert-find"
  • 8a250201494fa0864c81ba0bb2d16a485cdd2533 Revert "cert_find: fix call with --all"
  • fa3a69f91fcb4e15714f78a6eee4944bb8ca5e1b Use the python-cryptography parser directly in cert-find

ipa-4-10:

  • 276138087158c6b2ea76b43c754084144e543c0b Revert "Use the OpenSSL certificate parser in cert-find"
  • d83a4b0babdc7beb124d3748b5815ce309739eb7 Revert "cert_find: fix call with --all"
  • d9aa75459d650e5282a160a3eef09ed175dc5b51 Use the python-cryptography parser directly in cert-find

ipa-4-9:

  • 9fe30f21c987bdccf80ef5f6d645fdc59b393bdb Revert "Use the OpenSSL certificate parser in cert-find"
  • 3b1dbcdba2994bf57908f530913998e9ab888e4c Revert "cert_find: fix call with --all"
  • d00fd3398c32beb2c3e72f4878c87f9d2c0e833d Use the python-cryptography parser directly in cert-find
Metadata