Example: Associating a leaf certificate with a switch feature using REST APIs

The following example associates the signed certificatemy-cert-namewith the HTTPS server switch feature. For complete information about the switch features to which you can associate a leaf certificate, see theAOS-CXSecurity Guide.

Procedure
  1. Get the configuration attributes of thesystemresource:

    Example method and URI:

    GET "https://192.0.2.5/rest/v10.04/system?selector=configuration"

    Example curl command:

    $curl --noproxy 192.0.2.5 -k GET \ -b /tmp/primary_auth_cookie \ "https://192.0.2.5/rest/v10.04/system?selector=configuration"

    On successful completion, the switch returns response code 200 and a JSON object containing the configuration attributes.

  2. In the portion of the response body that defines the certificate name for the HTTPS server, change the value to:my-cert-name.

    The certificate name associated with the HTTPS server is the value assigned to thehttps-serverkey, which is under thecertificate_associationkey. By default, the certificate name is:local-cert

    The request body of a PUT request is permitted to include only the mutable configuration attributes. In theAOS-CXsoftware releases to which this example applies, all the configuration attributes for thesystem资源是可变的属性,所以你不需要d to edit the JSON object to remove the immutable attributes.

  3. Using a PUT request, update the system resource with the edited JSON data as the request body.

    Example method and URI:

    PUT "https://192.0.2.5/rest/v10.04/system"

    Example request body:

    { "aaa": { ... }, ... "certificate_association": { "https-server": "my-cert-name", "syslog-client": "local-cert" }, ... }

    Example curl command:

    $curl --noproxy 192.0.2.5 -k -X PUT \ -b /tmp/primary_auth_cookie \ -d '{ "aaa": { ... }, ... "certificate_association": { "https-server": "my-cert-name", "syslog-client": "local-cert" }, ... }' "https://192.0.2.5/rest/v10.04/system"

    On successful completion, the switch returns response code 200 OK.