The PKI JSON API the revocation reason key may be case-sensitive

PKI 11.4.0 changed the reason keyword in the REST API from lower-case
to camel-case in https://github.com/dogtagpki/pki/commit/926eb221ce6

Use Reason instead of reason as the keyword for revocations
for PKI 11.4.0+

Related: https://pagure.io/freeipa/issue/9345

Signed-off-by: Rob Crittenden <rcritten@redhat.com>
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
This commit is contained in:
Rob Crittenden 2023-09-11 21:37:05 +00:00 committed by Florence Blanc-Renaud
parent ed6fa6029d
commit 56a2bc5775

View File

@ -274,6 +274,8 @@ if six.PY3:
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
pki_version = pki.util.Version(pki.specification_version())
# These are general status return values used when # These are general status return values used when
# CMSServlet.outputError() is invoked. # CMSServlet.outputError() is invoked.
CMS_SUCCESS = 0 CMS_SUCCESS = 0
@ -1130,7 +1132,11 @@ class ra(rabase.rabase, RestClient):
serial_number = int(serial_number, 0) serial_number = int(serial_number, 0)
path = 'agent/certs/{}/revoke'.format(serial_number) path = 'agent/certs/{}/revoke'.format(serial_number)
data = '{{"reason":"{}"}}'.format(reasons[revocation_reason]) if pki_version < pki.util.Version("11.4.0"):
keyword = "reason"
else:
keyword = "Reason"
data = '{{"{}":"{}"}}'.format(keyword, reasons[revocation_reason])
http_status, _http_headers, http_body = self._ssldo( http_status, _http_headers, http_body = self._ssldo(
'POST', path, 'POST', path,