| Solution | REST API can be used to automate certificate updates in FortiWeb. This will help administrators save time for bulk certificate updates in FortiWeb. - Request Method: GET/PUT.
- Host header.
- Authorization header.
Encode the string with BASE64 and use it as an Authorization token. {“username”:”admin”,”password”:“a”,”vdom”:”root”} -
Content-Type: application/json header. List the target server policy: GET /api/v2.0/cmdb/server-policy/policy?mkey=DVWA Note: 'DVWA' is the server policy name. Sample request: curl --location 'https://<FWB_Host>/api/v2.0/cmdb/server-policy/policy?mkey=DVWA \ --header 'Authorization: <BASE64-token>' Sample response: { "results": { "can_view": 0, "q_ref": 0, "can_clone": 1, "q_type": 1, "name": "DVWA", "deployment-mode": "server-pool", "deployment-mode_val": "4", "protocol": "HTTP", "protocol_val": "0", "ssl": "enable", "ssl_val": "1", "implicit_ssl": "disable", "implicit_ssl_val": "0", "vserver": "DVWA_VS", "vserver_val": "3174", "v-zone": "", "v-zone_val": "0", "certificate": "", "certificate-group": "", "intermediate-certificate-group": "", } ] } Update the server policy certificate. PUT /api/v2.0/cmdb/server-policy/policy?mkey=DVWA Sample request. curl --location --request PUT 'https://<FWB_Host>/api/v2.0/cmdb/server-policy/policy?mkey=DVWA' \ --header 'Authorization: <BASE64-token>' \ --header 'Content-Type: application/json' \ --data '{"data":{"certificate":"ex-cert"}}' Note: ‘ex-cert’ is the local certificate name. Sample response. { "results": { "can_view": 0, "q_ref": 0, "can_clone": 1, "q_type": 1, "name": "DVWA", "deployment-mode": "server-pool", "deployment-mode_val": "4", "protocol": "HTTP", "protocol_val": "0", "ssl": "enable", "ssl_val": "1", "implicit_ssl": "disable", "implicit_ssl_val": "0", "vserver": "DVWA_VS", "vserver_val": "3174", "v-zone": "", "v-zone_val": "0", "certificate": "ex-cert", "certificate-group": "", "intermediate-certificate-group": "", } ] } Related documents: FortiWeb REST API reference Technical Tip: How to upload the local certificate to FortiWeb using the REST API |