VMware Cloud Community
kbollert
Contributor
Contributor

Error message when putting new certificates to VCenter via REST API

Hi,

I'm trying to automate the renewal of the VCenter TLS certificate via REST API.

Getting an error message when sending the certs via curl

curl -X PUT -H "vmware-api-session-id: sessionid" -H "Content-Type: application/json" -d '{"cert":"cert.crt","key":"cert.key","root_cert":"root-ca.crt"}' https://vcenter/api/vcenter/certificate-management/vcenter/tls

{"error_type":"ERROR","messages":[{"args":["String index out of range: -1"],"default_message":"Exception found (String index out of range: -1)","id":"com.vmware.certificatemanagement.error"}]}

  • 7.0.3
  • Build: 20051473

Anyone ever seen this?

thx

best regards, Karsten

0 Kudos
2 Replies
maksym007
Expert
Expert

I don't know if someone here has replaced Cert via restapi. Probably all done in a standard way via GUI or SSH. 

0 Kudos
lamw
Community Manager
Community Manager

If you look at the vSphere REST API documentation https://developer.vmware.com/apis/vsphere-automation/latest/vcenter/api/vcenter/certificate-manageme..., the value for the certificate is NOT the file itself but rather the contents of the file, hence the string format

0 Kudos