DMTF/python-redfish-library

Unable to upload certificate file

Closed this issue · 3 comments

Below is the command which we have to upload the certificate file. Here we have -T option for providing certificate file.

curl -c cjar -b cjar -k -H "X-Auth-Token: $bmc_token" -H "Content-Type: application/octet-stream" -X POST -T <certificate_file_path> https://${BMC_IP}/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates

We have tried to upload certificate file in below manner but its not working and we are getting "Invalid certificate file" in BMC's journal logs.

payload = {"data": <certificate_content>}
response = REDFISH_OBJ.post("BMC_IP}/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates", body=payload)

Please let us know if our approach is correct or not. If not, what is the correct way to upload a file using redfish python library?

Since this is a POST to the Certificate Collection, the representation needs to the a Certificate resource. This means you'll need to change Content-Type to be "application/json", and the payload will need to be a JSON object containing the RequiredOnCreate properties of the Certificate resource, which are the "CertificateString" and "CertificateType" properties. For example:

{
    "CertificateType": "PEM",
    "CertificateString": "-----BEGIN CERTIFICATE-----\n<Rest of Cert Data>-----END CERTIFICATE-----"
}

Does the curl command you're using work on the implementation you're using? I would not expect that to be valid.

@mraineri : Thanks for all the info. It has helped us in figuring out that our development code is not fully redfish compliant.