POST api/v1/trust-management/certificates/action/replace-host-certificate/<TN_UUID>
{ "display_name": "cert_sample", "pem_encoded": "-----BEGIN CERTIFICATE-----\n<cert>\n-----END CERTIFICATE-----", "private_key": "-----BEGIN PRIVATE KEY-----\n<private_key>\n-----END PRIVATE KEY-----"}POST api/v1/trust-management/certificates/action/replace-host-certificate/<TN_UUID>, counting line by wc command on ESXi host shows the certificate "host-cert.pem" has only 2 or less.wc -l /etc/vmware/nsx/host-cert.pem2 /etc/vmware/nsx/host-cert.pem<TIMESTAMP> Wa(180) nsx-proxy[<PID>]: NSX <PID> - [nsx@6876 comp="nsx-esx" subcomp="nsx-proxy" s2comp="nsx-rpc" tid="<TID>" level="WARNING"] RpcConnection[522067 Connecting to ssl://<NSX_MANAGER>:1235 0] Couldn't connect to ssl://<NSX_MANAGER>:1235 (error: 336151574-sslv3 alert certificate unknown)<TIMESTAMP> In(<INT>) NSX[<PID>]: Generating the certificate<TIMESTAMP> In(<INT>) NSX[<PID>]: Generating host certificate with TN uuid = .<TIMESTAMP> In(<INT>) NSX[<PID>]: Deleting the /etc/vmware/nsx/host-privkey.pem and /etc/vmware/nsx/host-cert.pem.NSX 4.x
nsx-proxy validates the host certificate if it has more than 2 lines with wc command.
If there are only 2 lines or less, nsx-proxy generates a new certificate and replaces the original certificate.
Because the newly generated certificate is not trusted by NSX Manager, the connection from ESXi host is rejected by NSX Manager.
To restore from disconnected state, push host certificate from ESXi host to NSX Manager.
get certificate api thumbprintnsxcli -c "push host-certificate <Manager hostname-or-IP> username admin thumbprint <thumbprint from step 1>"