/ssl/generate_csr
POST https://api.sitehost.nz/1.0/ssl/generate_csr.json
Creates a CSR for the requested information.
Form Parameters
Parameter | Type | Required | Description |
client_id | integer | Yes | The ID for the client.Example: 1 |
params[countryName] | string | Yes | The two character country code.Example: NZ |
params[stateOrProvinceName] | string | Yes | The name of the state or province.Example: Auckland |
params[localityName] | string | The name of the locality.Example: Auckland | |
params[organizationName] | string | Yes | The name of the organization.Example: Example, Inc. |
params[organizationalUnitName] | string | The name of the organizational unit.Example: Applied Sciences | |
params[commonName] | string | Yes | The common name for the certificate (the host name for the website).Example: www.example.com |
params[emailAddress] | string | A contact email address for the certificate.Example: bruce@example.com |
Code Samples
JavaScript PHP Rails Pythonvar xmlHttp = new XMLHttpRequest();
xmlHttp.open("POST", "https://api.sitehost.nz/1.0/ssl/generate_csr.json", false);
var data = new FormData();
data.append("apikey", "your_key_here");
data.append("client_id", "1");
data.append("params[countryName]", "NZ");
data.append("params[stateOrProvinceName]", "Auckland");
data.append("params[localityName]", "Auckland");
data.append("params[organizationName]", "Example, Inc.");
data.append("params[organizationalUnitName]", "Applied Sciences");
data.append("params[commonName]", "www.example.com");
data.append("params[emailAddress]", "bruce@example.com");
xmlHttp.send(data);
var response = xmlHttp.responseText;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sitehost.nz/1.0/ssl/generate_csr.json");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$body = array(
'apikey' => 'your_key_here',
'client_id' => 1,
'params[countryName]' => 'NZ',
'params[stateOrProvinceName]' => 'Auckland',
'params[localityName]' => 'Auckland',
'params[organizationName]' => 'Example, Inc.',
'params[organizationalUnitName]' => 'Applied Sciences',
'params[commonName]' => 'www.example.com',
'params[emailAddress]' => 'bruce@example.com',
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
require 'net/http'
require 'uri'
uri = URI.parse("https://api.sitehost.nz/1.0/ssl/generate_csr.json")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri)
body = {"apikey" => "your_key_here",
"client_id" => 1,
"params[countryName]" => "NZ",
"params[stateOrProvinceName]" => "Auckland",
"params[localityName]" => "Auckland",
"params[organizationName]" => "Example, Inc.",
"params[organizationalUnitName]" => "Applied Sciences",
"params[commonName]" => "www.example.com",
"params[emailAddress]" => "bruce@example.com",
}
request.set_form_data(body)
response = http.request(request)
import requests
from collections import OrderedDict
uri = 'https://api.sitehost.nz/1.0/ssl/generate_csr.json'
# We need ordered dictionary because parameters have to be in the right order.
# Refer to Developer Notes for more information.
body = OrderedDict()
body['apikey'] = 'your_key_here'
body['client_id'] = 1
body['params[countryName]'] = 'NZ'
body['params[stateOrProvinceName]'] = 'Auckland'
body['params[localityName]'] = 'Auckland'
body['params[organizationName]'] = 'Example, Inc.'
body['params[organizationalUnitName]'] = 'Applied Sciences'
body['params[commonName]'] = 'www.example.com'
body['params[emailAddress]'] = 'bruce@example.com'
response = requests.post(uri, data=body)
Response
200:application/json
{
"return": {
"cert_id": "11",
"csr": "csr content here"
},
"msg": "Successful.",
"status": true,
"time": 245.89
}
"return": {
"cert_id": "11",
"csr": "csr content here"
},
"msg": "Successful.",
"status": true,
"time": 245.89
}