NSX Certificate Management Using Rest API

In this post We will learn how to view generate self-signed certificate for NSX and replace the certificates after getting them signed from CA. We will be doing this via Rest API.

I wrote a post in past on how to replace SSL certs for NSX from GUI. In this post I am trying to achieve the same via Rest API

Following are the API queries which you need to execute in order to generate and replace certs.

Generate CSR Certificate

# curl -k -u “admin:passwd” -d @csr.xml -X PUT https://nsxmgr.alex.local/api/1.0/appliance-management/certificatemanager/csr/nsx

Download CSR Certificate

# curl -k -u “admin:passwd” -X GET https://nsxmgr.alex.local/api/1.0/appliance-management/certificatemanager/csr/nsx

Note: If you have not generated the csr yet and try to download the csr certificate, you are going to get below error

Upload Certificate Chain

Once you recieve the signed certificate from your certification authority, you can apply the cert to NSX manager using below API call

# curl -k -u “admin:passwd” -X PUT https://NSX-Manager-IP-Address/api/1.0/appliance-management/certificatemanager/uploadchain/nsx

Query Certificates

Once you have replaced the ssl certificates on NSX, you can query the installed certificate using below API call

# curl -k -u “admin:passwd” -X GET https://nsxmgr.alex.local/api/1.0/appliance-management/certificatemanager/certificates/nsx | xmllint –format –

Sources and Additional Reading

NSX Rest API Guide

I hope you enjoyed reading this post. Feel free to share this on social media if it is worth sharing. Be sociable :)