UAPI Functions - SSL::generate_csr

Description

This function generates a Certificate Signing Request (CSR).

Note:

This function requires a valid key in the account's ssl directory.

Examples 


 cPanel or Webmail Session URL

https://hostname.example.com:2083/cpsess##########/execute/SSL/generate_csr?domains=example.com&pass=12345luggage&countryName=US&stateOrProvinceName=Texas&localityName=Houston&organizationName=Organization&organizationalUnitName=Department&emailAddress=user%40example.com&key_id=example_com_a74f7_9dddf_1446659822_eae1ff43c4ec1991e195877c55755eff&friendly_name=TestCSR

 LiveAPI PHP Class

$cpanel new CPANEL(); // Connect to cPanel - only do this once.
  
// Generate a certificate signing request for the example.com site.
$SSL_generate_csr $cpanel->uapi(
    'SSL''generate_csr',    array(
           'key_id'                  => 'example_com_a74f7_9dddf_1446659822_eae1ff43c4ec1991e195877c55755eff',
           'pass'                    => '12345luggage',
           'domains'                 => 'example.com',
           'countryName'             => 'US',
           'stateOrProvinceName'     => 'Texas',
           'localityName'            => 'Houston',
           'organizationName'        => 'Organization',
           'organizationalUnitName'  => 'Department',
           'emailAddress'            => 'user@example.com',
           'friendly_name'           => 'TestCert',
 )
);

 LiveAPI Perl Module

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
  
# Generate a certificate signing request for the example.com site.
my $SSL_generate_csr $cpliveapi->uapi(
    'SSL''generate_csr',    {
           'key_id'                  => 'example_com_a74f7_9dddf_1446659822_eae1ff43c4ec1991e195877c55755eff',
           'pass'                    => '12345luggage',
           'domains'                 => 'example.com',
           'countryName'             => 'US',
           'stateOrProvinceName'     => 'Texas',
           'localityName'            => 'Houston',
           'organizationName'        => 'Organization',
           'organizationalUnitName'  => 'Department',
           'emailAddress'            => 'user@example.com',
           'friendly_name'           => 'TestCert',
    }
);

 cPanel Template Toolkit

<!--  Generate a certificate signing request for the example.com site.-->
[% data = execute( 'SSL', 'generate_csr', { pass => '12345luggage', friendly_name => 'TestCSR', domains => 'example.com', countryName => 'US', stateOrProvinceName' => 'Texas', localityName => 'Houston', organizationName => 'Organization', organizationalUnitName => 'Department', emailAddress => 'user@example.com', key_id => 'example_com_a74f7_9dddf_1446659822_eae1ff43c4ec1991e195877c55755eff', friendly_name => 'TestCert',} ); %]
[% FOREACH q = data %]
     <p>
         [% q %]
     </p>
[% END %]

 Command Line

uapi --user=username SSL generate_csr domains=example.com pass=12345luggage countryName=US stateOrProvinceName=Texas localityName=Houston organizationName=Organization organizationalUnitName=Department emailAddress=user%40example.com key_id=example_com_a74f7_9dddf_1446659822_eae1ff43c4ec1991e195877c55755eff friendly_name=TestCSR

 

Notes:

  • You must URI-encode values.
  • username represents your account-level username.

 Output (JSON)

{
  "data": {
    "commonName": "example.com",
    "created": "1366386445",
    "domains": [
      "example.com"
    ],
    "friendly_name": "example.com",
    "id": "example_com_bbe7e_16e2d_a626d1b34b62cefb13076a25b6831ca5",
    "modulus": "THE MODULUS",
    "text": "-----BEGIN CERTIFICATE REQUEST-----
MIIC3TCCAcUCAQAwgZcxFDASBgNVBAMMC2V4YW1wbGUuY29tMRYwFAYDVQQLDA1E
b2N1bWVudGF0aW9uMQswCQYDVQQGEwJVUzEiMCAGCSqGSIb3DQEJARYTbGF1cmVu
Y2VAY3BhbmVsLm5ldDEUMBIGA1UECgwLY1BhbmVsIEluYy4xDjAMBgNVBAgMBVRl
eGFzMRAwDgYDVQQHDAdIb3VzdG9uMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
CgKCAQEAp092NvpqyT7mg2qDqZW1XetQGeo217o9r7AOONaTrNsMgbL/d31rQzpC
D65SPxJ/NSpovMi48tbue3A5W6+r2CN62oFk/d34N2swN1w11NTLzOfTPQgGnBe0
CRdqNonx68l8Cwj+auRMGakqxtaESOfx0T87Ngr/1CIqUbTzU0LembWh+1VI5Djy
2CRmRWKkSAAu7X/OJN7cfcPh7ReZc9Ha6VmzNxbutBDRcnCJVOAGMsv2Cg4mQZhg
yMC8KF1r/ktHneDdGJdypdrmdr0qkqzMwTaYIb6M/93Yp+bswGH4oyqa4GYeTpRu
2OOCeydxONOnYRZWfL0SnL2Gnvnd3wIDAQABoAAwDQYJKoZIhvcNAQEFBQADggEB
AFlolzJbcviWcdZUv+PJ7G8cAqFAxa8a3W2a0Y1U0BaMrpDfuOHpQgOtO62rr+i+
hkrIReuk7Isyl6GoZkX17KhQ1Vo9aW8a8Ur7+0RGDbxRlK9jJWnvSFn6cMMqRSfA
DXpptxhqBFZJIZMc3pPX9Jqycuu8bxeIvUKeSMe3Jxcl1ZXEXX47FeRZxvd+WXF9
4Xu4KZXHdzb5tB6jPhzIaN0/3d92N/KhvCcnw3YC2fEGDkpOlZaoa7O72+aq5K3b
M1htFv9deAHqIHefV41iOrxUCIKIhdPIjvAm774lDHLzPpJVrshO/NpA74LEkny5
FMwKKx+6Jgx1HSWucn5kWek=
-----END CERTIFICATE REQUEST-----\n"
  },
  "errors": null,
  "messages": [
    "Certificate Signing Request generated!"
  ],
  "status": 1
}

 

Note:

Use cPanel's API Shell interface (Home >> Advanced >> API Shell) to directly test cPanel API calls.

 

Parameters

Parameter

Type

Description

Possible values

Example

domains

string

Required

The domain(s) for which to generate the certificate.

A valid string.

Note:

 If there is more than one domain, this parameter mustbe a comma-separated list. 

example.com

countryName

string

Required

The two-letter country code.

A valid two-letter ISO-3166 country code.

US

stateOrProvinceName

string

Required

The state's or locality's full name.

A valid string.

Texas

localityName

string

Required

The certificate's city name.

A valid string.

Houston

organizationName

string

Required

The certificate's organization.

A valid string.

Organization

 organizationalUnitName 

string

The certificate's organizational unit or department name.

This parameter defaults to an empty string.

A valid string.

Department

emailAddress

string

A valid email address to associate with the certificate.

This parameter defaults to an empty string.

A valid email address.

 user@example.com 

key_id

string

Required

The key's ID.

A valid string.

 

friendly_name

 string 

A friendly name for the new certificate.

 This parameter defaults to the domain name for which you generated the certificate. 

A valid string.

TestCert

 

Returns

Return

Type

Description

Possible values

Example

modulus

string

The CSR's modulus.

A valid string.

 

created

string

When the CSR was created.

 A valid date in Unix time format. 

1366386445

domains

string

 The domains that the CSR covers. 

A valid domain or domains.

 example.com 

 commonName 

string

The name that issued the CSR.

Usually, a valid domain.

example.com

friendly_name

 string 

The CSR's friendly name.

A valid string.

TestCSR

id

string

The CSR's ID.

A valid string.

 

text

string

The CSR's text.

A valid CSR.

 

 

 

 
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

The cPanel Interface

For  cPanel  &  WHM  version  58 Overview The cPanel interface is...

User Preferences

For cPanel & WHM version 58 Overview This document outlines how to access your cPanel...

Manage External Authentications

For cPanel & WHM version 58 Overview Manage credentials Additional documentation...

What is cPanelID?

In This Article:  Overview ServicesHow to get a cPanelID cPanelID External...

Guide to cPanel Interface Customization - cPanel Style Development

Introduction You can develop custom styles that modify the appearance of the cPanel interface....