UAPI Functions - SSL::generate_cert

Description

This function generates a self-signed SSL certificate.

Examples 


 cPanel or Webmail Session URL

https://hostname.example.com:2083/cpsess##########/execute/SSL/generate_cert?domains=example.com&countryName=US&stateOrProvinceName=TX&localityName=Houston&organizationName=Organization&organlizationalUnitName=Department&emailAddress=user%40example.com&key_id=example_com_a74f7_9dddf_1446659822_eae1ff43c4ec1991e195877c55755eff&friendly_name=TestCert

 LiveAPI PHP Class

$cpanel new CPANEL(); // Connect to cPanel - only do this once.
  
// Generate a self-signed certificate for the example.com site.
$SSL_generate_cert $cpanel->uapi(
    'SSL''generate_cert',    array(
           'friendly_name'           => 'TestKey',
           'domains'                 => 'example.com',
           'countryName'             => 'US',
           'stateOrProvinceName'     => 'TX',
           'localityName'            => 'Houston',
           'organizationName'        => 'Organization',
           'organlizationalUnitName' => 'Department',
           'emailAddress'            => 'user@example.com',
           'key_id'                  => 'example_com_a74f7_9dddf_1446659822_eae1ff43c4ec1991e195877c55755eff',
           'friendly_name'           => 'TestCert',
 )
);

 LiveAPI Perl Module

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
  
# Generate a self-signed certificate for the example.com site.
my $SSL_generate_cert $cpliveapi->uapi(
    'SSL''generate_cert',    {
           'friendly_name'           => 'TestKey',
           'domains'                 => 'example.com',
           'countryName'             => 'US',
           'stateOrProvinceName'     => 'TX',
           'localityName'            => 'Houston',
           'organizationName'        => 'Organization',
           'organlizationalUnitName' => 'Department',
           'emailAddress'            => 'user@example.com',
           'key_id'                  => 'example_com_a74f7_9dddf_1446659822_eae1ff43c4ec1991e195877c55755eff',
           'friendly_name'           => 'TestCert',
    }
);

 cPanel Template Toolkit

<!--  Generate a self-signed certificate for the example.com site. -->
[% data = execute( 'SSL', 'generate_cert', { friendly_name => 'TestKey', domains => 'example.com', countryName => 'US', stateOrProvinceName' => 'TX', localityName => 'Houston', organizationName => 'Organization', organlizationalUnitName => '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_cert domains=example.com countryName=US stateOrProvinceName=TX localityName=Houston organizationName=Organization organlizationalUnitName=Department emailAddress=user%40example.com key_id=example_com_a74f7_9dddf_1446659822_eae1ff43c4ec1991e195877c55755eff&friendly_name=TestCert

 

Notes:

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

 Output (JSON)

{
  "data": {
    "created": 1366386266,
    "domains": [
      "example.com"
    ],
    "friendly_name": "example.com",
    "id": "example_com_bbe7e_16e2d_1397922266_a6e1ed42e59ce03e863b96ccde8d192f",
    "is_self_signed": 1,
    "issuer.commonName": "example.com",
    "issuer.organizationName": "Organization",
    "modulus": "a74f7636fa6ac93ee6836a83a995b55deb5019ea36d7ba3dafb00e38d693acdb0c81b2ff777d6b433a420fae523f127f352a68bcc8b8f2d6ee7b70395bafabd8237ada8164fdddf8376b30375c35d4d4cbcce7d33d08069c17b409176a3689f1ebc97c0b08fe6ae44c19a92ac6d68448e7f1d13f3b360affd4222a51b4f35342de99b5a1fb5548e438f2d824664562a448002eed7fce24dedc7dc3e1ed179973d1dae959b33716eeb410d172708954e00632cbf60a0e26419860c8c0bc285d6bfe4b479de0dd189772a5dae676bd2a92acccc1369821be8cffddd8a7e6ecc061f8a32a9ae0661e4e946ed8e3827b277138d3a76116567cbd129cbd869ef9dddf",
    "modulus_length": 2048,
    "not_after": 1397922266,
    "not_before": 1366386266,
    "subject.commonName": "example.com",
    "text": "-----BEGIN CERTIFICATE-----
MIIDcTCCAlmgAwIBAgIFAU+BNVgwDQYJKoZIhvcNAQEFBQAwUTESMBAGA1UEAwwJ
c2lza28udGxkMQswCQYDVQQGEwJVUzEPMA0GA1UECgwGY1BhbmVsMQswCQYDVQQI
DAJUWDEQMA4GA1UEBwwHSG91c3RvbjAeFw0xNDEwMDYyMjI2MTlaFw0xNTEwMDYy
MjI2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

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 two-letter state or locality abbreviation.

A valid two-letter string.

TX

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's name for which you generated the certificate. 

A valid string.

TestCert

 

Returns

Return

Type

Description

Possible values

Example

is_self_signed

 Boolean 

Whether the certificate is self-signed.

  • 1 — Self-signed.
  • 0 — Not self-signed.

1

 issuer.organizationName 

string

The certificate's organization name.

A valid string.

Organization

modulus

string

The certificate's modulus.

A valid string.

 

issuer.commonName

string

The certificate's common name.

A valid domain.

 example.com 

not_before

string

When the certificate started.

 A date in Unix time format. 

1415123822

modulus_length

string

 The length of the certificate's modulus. 

A positive integer.

2048

not_after

string

When the certificate expired.

A date in Unix time format.

1446659822

domains

string

The domains that the certificate covers.

A valid domain or domains.

example.com

subject.commonName

string

The name that issued the certificate.

Usually, a valid domain.

example.com

friendly_name

string

The certificate's friendly name.

A valid string.

TestCert

id

string

The certificate's ID.

A valid string.

 

text

string

The certificate's text.

A valid certificate.

 

 

  • 10 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....