OpenKMIP / PyKMIP

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

How to use set_attribute with custom_attribute #663

Open loknath01 opened 2 years ago

loknath01 commented 2 years ago

I am unable to set the custom attributes using set_attribute, could someone help me on this?

python version: 3.8.10 pykmip version: 0.10.0

requirenment: Need to pass different data types into x-value field example: attr_name= "dummy name" attr_value="dummy text" --> data type of attr_value can be datetime or string or int

masks=enums.CryptographicUsageMask.DERIVE_KEY]) id = client.register(secret_data)

attribute_v = '{"kmip-x-AttributeName": "TextString:HELLO"}' client.set_attribute(unique_identifier=id, attribute_name="Custom Attribute", attribute_value=attribute_v)`

image

arp102 commented 2 years ago

The main issue here is that there's no KMIP version that supports both the "Set Attribute" operation and the "Custom Attribute" attribute. The KMIP 2.0 spec added "Set Attribute" and replaced "Custom Attribute" with "Attribute" (sometimes referred to as "Vendor Attribute").

Unfortunately, PyKMIP does not fully support all of the attributes added in the 2.0 spec, so if you changed "Custom Attribute" to "Attribute" then you would still get an exception in the client. It should be pretty easy to add support for "Attribute" though if anyone wants to make that pull request.

You could also try to find a workaround using a different KMIP version, a different operation like modify_attribute, or a different attribute type.