OpenKMIP / PyKMIP

A Python implementation of the KMIP specification.
Apache License 2.0
272 stars 134 forks source link

kmip 1.4 server -> pykmip client error with server_correlation_value in header #675

Closed jvinokurovs closed 1 year ago

jvinokurovs commented 2 years ago

Hello!

I have some issue with kmip client (ProxyKmipClient/PyKMIP 0.10.0), when requesting symmetric key from KMIP server using kmip version 1.4 server response contains server_correlation_value which is a "Not Required" Response Header field in KMIP spec starting from 1.4:

RESPONSE_MESSAGE:STRUCTURE(240):stru1 RESPONSE_HEADER:STRUCTURE(120):stru2 PROTOCOL_VERSION:STRUCTURE(32):stru3 PROTOCOL_VERSION_MAJOR:INTEGER(4):1 PROTOCOL_VERSION_MINOR:INTEGER(4):4 TIME_STAMP:DATE_TIME(8): SERVER_CORRELATION_VALUE:TEXT_STRING(36):b'' BATCH_COUNT:INTEGER(4):1 BATCH_ITEM:STRUCTURE(104):stru2 OPERATION:ENUMERATION(4):CREATE RESULT_STATUS:ENUMERATION(4):SUCCESS

the ProxyKmipClient fails with error: kmip.core.exceptions.ReadValueError: Tried to read Base.tag: expected 0x42000d, received 0x420106 (trying to read batch count, but getting server_correlation_value)

I did some fix kmip/core/messages/messages.py, line 210 added this: if self.is_tag_next(enums.Tags.SERVER_CORRELATION_VALUE, tstream): server_correletion_value = primitives.TextString(tag=enums.Tags.SERVER_CORRELATION_VALUE) server_correletion_value.read(tstream, kmip_version=kmip_version) in ResponseHeader.read

which fixed the problem. Are these fields not supported in current version of a client? Thank you!

arp102 commented 2 years ago

No, the server_correlation_value is not currently supported, but it would be good to fix that error when it (or any of the other optional fields) is present. I think you found the right place to fix it in ResponseHeader.read().

Response Header reference: https://docs.oasis-open.org/kmip/kmip-spec/v2.0/os/kmip-spec-v2.0-os.html#_Toc6497625

arp102 commented 1 year ago

Addressed in #695