Use the LetEncrypt Install Certificate API to install the certificate issued by Let’s Encrypt. Let's Encrypt is a free, automated, and open Certificate Authority (CA). It will issue certificate for your domain names for free after domain name verification and Virtualizor from version 2.8.8 onward has integrated this feature.
The API response will contain "done" as the message "Configuration saved successfully" after the certificate is installed successfully.
For more information, you can refer this Let's Encrypt Certificate Installation Guide.
HTTP Request
https://hostname:4085/index.php?act=letsencrypt
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | letsencrypt | The action will return the certificate config and done as "Configuration saved successfully" | Yes |
opt | POST | text | For installing the certificate this value should be "save_crt" | Yes |
primary_domain | POST | text | The primary domain will be required to point the ssl to the correct domain | Yes |
contact_email | POST | text | The users email who will be installing the certificate | Yes |
key_size | POST | Int | Refers to privake key size in bits i.e the strength of the private key, refer below table for valid values | Yes |
renew_days | POST | Int | The day for the certificate's expiration | Yes |
staging | POST | 1/0 | If set then Lets Encrypts test certificate will be installed on the system | No |
enable_force | POST | 1/0 | If the certificate needs to be re-installed on the system then this option should be enabled | Yes |
Languages
( 2048 | 3072 | 4096 | 8192 | ec-256 | ec-384 ) |
Sample Code
<?php
require_once('/usr/local/virtualizor/sdk/admin.php');
$key = 'your_api_key';
$pass = 'your_api_pass';
$ip = 'your_server_ip';
$admin = new Virtualizor_Admin_API($ip, $key, $pass);
$post = array();
$post['opt'] = 'save_cfg';
$post['primary_domain'] = 'hostname';
$post['contact_email'] = 'test@test.com';
$post['key_size'] = 2048;
$post['renew_days'] = 80;
$post['staging'] = 0;
$post['enable_force'] = 1;
$output = $admin->letsencrypt($post);
print_r(json_encode($output));
?>
Output
{
"title": "LetsEncrypt",
"done": "Configuration saved successfully",
"crt_config_options": {
"crt_save_cfg_frm": {
"inputs": {
"primary_domain": {
"type": "text",
"value": "hostname"
},
"contact_email": {
"type": "text",
"value": "test@test.com"
},
"key_size": {
"type": "select",
"value": "2048"
},
"renew_days": {
"type": "text",
"value": "80"
},
"staging": {
"type": "checkbox",
"value": "0"
},
"enable_force": {
"type": "checkbox",
"value": "1"
}
}
}
},
"crt_details": {
"crt_domain": "",
"crt_san": "",
"crt_issuer": "",
"crt_serialno": "",
"crt_valid_from_time": "",
"crt_valid_to_time": "",
"next_renew": "",
"crt_installed": "No"
},
"actid": "3413",
"logs": "null",
"timenow": "1478743086",
"time_taken": "1.608"
}