Import a CA-signed certificate

put

/rest/{version}/configuration/certificates/import

This API allows a REST client to import a CA-signed certificate. X509 and PKCS7 format certificates are supported. The client making this request must already possess the configuration lock or the request fails. If one or more attributes or sub-elements in the request is syntactically invalid in any way, this request fails and the certificate will not be imported.

Request

Path Parameters
  • REST API version string.
    Available values: v1.2
Header Parameters
  • The value in the Authorization header must be the string "Bearer {access token}", where {access token} is a valid, unexpired token received in response to a prior /rest/{version}/auth/token request.
Back to Top

Response

200 Response

OK - certificate record name in request body is returned in response body

400 Response

The request is malformed in some way or is missing required information and therefore cannot be processed.

401 Response

Unauthorized - Request lacks valid authentication credentials.

404 Response

Unsupported version ID in URI or unknown instance is requested in the URL.

423 Response

The request requires the configuration lock and failed because the client does not currently own the lock. If another client or user currently owns the configuration lock, the error message is "Resource locked by another user". If no client or user owns the configuration lock, the error message is "User does not have the lock".
Back to Top

Examples

Example of Accessing the API with cURL

The following example shows how to import a certificate by submitting a PUT request on the REST resource using cURL. For more information about cURL, see Use cURL.

curl -X PUT \
    -d@request.xml \
    --header "Content: application/xml" \
    --header "Authorization: Bearer $TOKEN" \
    "https://${SBCIP}/rest/v1.2/configuration/certificates/import"

The following shows an example of the contents of the request.xml file sent as the request body.

<?xml version="1.0" encoding="UTF-8"?>
<ImportCertificate>
    <recordName>rest-server</recordName>
    <format>x509</format>
    <certificateRequest>-----BEGIN CERTIFICATE-----
MIIFOjCCAyKgAwIBAgIBFDANBgkqhkiG9w0BAQUFADCBgTELMAkGA1UEBhMCVVMx
CzAJBgNVBAgMAk1BMRMwEQYDVQQHDApCdXJsaW5ndG9uMRQwEgYDVQQKDAtFbmdp
AAOCAQ8AMIIBCgKCAQEA6OpPYyfKXWmc1k3XUlzlDB37c8eiMdOMc2LafDRrmdxo
bmVlcmluZzEXMBUGA1UEAwwOQWNtZSBQYWNrZXQgTUExITAfBgkqhkiG9w0BCQEW
MTFaMEkxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJNQTEUMBIGA1UEChMLRW5naW5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9I40jT0uH+2TKQ4Ts9Nmv4+f0h2gNQ1BKULeEfqlFk9
1GMbICw/qjBI5pUmgarYpX1q5JqrRNYxtue+9xKAgtCD2MCGfn4C+wIUwLFcbg==
rSLw20eSce7CiFA8c9bL5iIRDQVD+Dhq8LpwnMaFK1PuqcE/9y8XHkTOajmHHRhx
30jwAbQtBwyywKItN++r22FqPOeUGnnn6VndJdHj20iOEoQ5Q3RS9PSM/oApRvxg
m5SQ37xqafnBgSe3iR5lzVXBC5LpCSGyuNxOfme9u5W+iVaypWromEVaEAdO7kKX
XHJG+Y8TRNsDsDbBwKbXYivyIhfrwjKWFiCtXI7le4RfbNTKSKbZdqFHdkMX/qEj
PI+CGBKyPYOXe90XoX9djrIaLJsbikUsZpr3YRqIiYFJA2MHHgrrnbNFJLvScziB
-----END CERTIFICATE-----</certificateRequest>
</ImportCertificate>

Example of Accessing the API with Python

The following example shows how to import a certificate by submitting a PUT request on the REST resource using Python. This example assumes you have a valid token stored in the token variable. For an example of authenticating with Python, see Authenticate.

import requests
from lxml import etree
headers = { "Accept":"application/xml", "Authorization":"Bearer " + token }
data = etree.tostring(etree.parse("request.xml"), xml_declaration=True, encoding="UTF-8")
data = data.decode('utf8')
url  = "https://" + sbcip + "/rest/v1.2/configuration/certificates/import"
resp = requests.put(url, headers=headers, data=data)

Example of the Response Headers

The following shows an example of the response headers.

HTTP/1.1 200
Server: nginx/1.14.1
Date: Mon, 14 Sep 2020 10:31:29 GMT
Content-Type: application/xml
Transfer-Encoding: chunked
Connection: keep-alive

Example of the Response Body

The following example shows the contents of the response body in XML format.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<response>
  <data>
    <ImportCertificate>
      <recordName>rest-server</recordName>
    </ImportCertificate>
  </data>
  <messages/>
  <links/>
</response>
Back to Top