百度智能云

All Product Document

          CDN

          Add & Modify the Domain Name Certificate

          Interface

          If a certificate id has been bound to the domain, the interface is for modification (replace the old certificate in the certificate library with the latest uploaded certificate by the user, and bind the new certificate id to the domain). If no certificate was bound to the domain before, this interface is to upload a new certificate and bind the new certificate id to the domain.

          method path Description
          PUT /v2/{domain}/certificates Add or modify the certificate bound by the domain

          url parameter

          Parameter Optional Type Description
          domain Required string Correlate the domain name of the target certificate

          Request body

          Parameter Optional Type Description
          httpsEnable Required string Only "ON" or "OFF" can be taken, which indicates if the https support of domain is enabled; “ON” indicates open, and "OFF" indicates close
          certificate Required certificate Certificate content

          certificateParameter description

          Parameter Optional Type Description
          certName String Required Name of the certificate. The length is limited to 1-65 characters. It starts with a letter and only contains letters, numbers, ‘-’, ’/’, ’.’, '_', and ’*’, Java regular expressions ^[a-zA-Z][a-zA-Z0-9\-/_\.\*]{0,64}$
          certServerData String Required Data content of the server certificate (Base64 encoded)
          certPrivateData String Required Certificate private key data content (Base64 encoded)
          certLinkData String Optional Certificate chain data content (Base64 encoded)
          certType Integer Optional Certificate type, 1: server certificate(default); 2: client certificate

          Response body

          Parameter Optional Type Description
          certId Required string CertId after certificate is added in the library

          Notice the 4 types of 500 conditions when using the interface, according to the returned code filed 1.“Unbind old certificate failed”, the domain is in the same status as that before the operation. Old certificate is neither unbound nor deleted, and new certificate is not added into the certificate library. 2."delete old certificate failed ", the domain and old certificate are unbound, but old certificate is still in the certificate library and not deleted, and new certificate is not added. 3."add new certificate failed ", the domain and old certificate are unbound, old certificate is deleted from the certificate library, but new certificate is not added. There is no certificate binding with the domain currently 4."bind new certificate failed ", the domain and old certificate are unbound, old certificate is deleted from the certificate library, new certificate is added in the library, but binding the new certificate and domain failed. There is no certificate binding with the domain currently

          Request example

          PUT /v2/www.example.com/certificates 
          { 
              "httpsEnable": "OFF", 
              "certificate": { 
                  "certName": "test", 
                  "certServerData": "-----BEGIN CERTIFICATE----END CERTIFICATE-----", 
                  "certPrivateData": "-----BEGIN RSA PRIVATE KEY----END RSA PRIVATE KEY-----" 
              } 
          } 

          Response example

          HTTP/1.1 100 Continue 
          
          HTTP/1.1 200 OK 
          Server: nginx 
          Date: Wed, 28 Aug 2019 08:10:51 GMT 
          Content-Type: application/json; charset=utf-8 
          Transfer-Encoding: chunked 
          Connection: keep-alive 
          X-Powered-By: PHP/7.1.5 
          x-bce-request-id: aa1f2344-711b-8332-3d2e-2849fd123e75
          
          {"certId":"xxx"} 
          Previous
          Access Control Interface
          Next
          Query the Domain Name Certificate