Class: Lumberg::Cpanel::Ssl

Inherits:
Base show all
Defined in:
lib/lumberg/cpanel/ssl.rb

Instance Attribute Summary

Attributes inherited from Base

#api_username

Attributes inherited from Whm::Base

#server

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, #perform_request

Methods inherited from Whm::Base

#initialize, #setup_server

Constructor Details

This class inherits a constructor from Lumberg::Cpanel::Base

Class Method Details

.api_moduleObject



4
# File 'lib/lumberg/cpanel/ssl.rb', line 4

def self.api_module; "SSL"; end

Instance Method Details

#fetchcabundle(options = {}) ⇒ Object

Public: Fetch the cabundle that corresponds to the certificate

options - Hash options for API call params (default: {}):

:crt   - Contents of the certificate file

Returns Hash API response.



113
114
115
116
117
# File 'lib/lumberg/cpanel/ssl.rb', line 113

def fetchcabundle(options = {})
  perform_request({
    api_function: "fetchcabundle",
  }.merge(options))
end

#gencrt(options = {}) ⇒ Object

Public: Generate a self-signed SSL certificate for a specific domain.

options - Hash options for API call params (default: {}):

:city     - The city in which your server resides.
:company  - The name of the company.
:company_division - The division of your company.
:country  - A two letter abbreviation for the country.
:email    - A valid email address that will correspond to
            the certificate signing request
:host     - The domain that corresponds to the csr.
:state    - A two letter abbreviation that corresponds to the
            state.

Returns Hash API response.



171
172
173
174
175
176
177
# File 'lib/lumberg/cpanel/ssl.rb', line 171

def gencrt(options = {})
  options[:companydivision] = options.delete(:company_division)

  perform_request({
    api_function: "gencrt",
  }.merge(options))
end

#gencsr(options = {}) ⇒ Object

Public: Generate a certificate signing request.

options - Hash options for API call params (default: {}):

:city     - The city in which your server resides.
:company  - The name of the company.
:company_division - The division of your company.
:country  - A two letter abbreviation for the country.
:email    - A valid email address that will correspond to
            the certificate signing request
:host     - The domain that corresponds to the csr.
:state    - A two letter abbreviation that corresponds to the
            state.
:pass     - The password of the csr.

Returns Hash API response.



148
149
150
151
152
153
154
155
# File 'lib/lumberg/cpanel/ssl.rb', line 148

def gencsr(options = {})
  options[:companydivision] = options.delete(:company_division)

  perform_request({
    api_function: "gencsr",
    response_key: "cpanelresult",
  }.merge(options))
end

#genkey(options = {}) ⇒ Object

Public: Generate an SSL key. You must have access to the 'sslmanager'.

options - Hash options for API call params (default: {}):

:host       - The domain that corresponds to the csr.
:keysize    - The size of the key
              Optional, may range from 1024 to 4096.

Returns Hash API response.



187
188
189
190
191
# File 'lib/lumberg/cpanel/ssl.rb', line 187

def genkey(options = {})
  perform_request({
    api_function: "genkey",
  }.merge(options))
end

#installssl(options = {}) ⇒ Object

Public: Install an SSL certificate, key, and cabundle.

options - Hash options for API call params (default: {}):

:cabundle - Contents of the CA bundle file (optional)
:crt      - Contents of the certificate file
:domain   - Domain name for the cert (optional)
:key      - Contents of the key file associated with the CSR
:subject - String subject line.

Returns Hash API response.



16
17
18
19
20
# File 'lib/lumberg/cpanel/ssl.rb', line 16

def installssl(options = {})
  perform_request({
    api_function: "installssl"
  }.merge(options))
end

#listcrts(options = {}) ⇒ Object

Public: List SSL certificates currently installed for a cPanel account.

options - Hash options for API call params (default: {}):

Returns Hash API response.



90
91
92
93
94
# File 'lib/lumberg/cpanel/ssl.rb', line 90

def listcrts(options = {})
  perform_request({
    api_function: "listcrts",
  }.merge(options))
end

#listcsrs(options = {}) ⇒ Object

Public: List CSRs associated with your cPanel account.

options - Hash options for API call params (default: {}):

Returns Hash API response.



27
28
29
30
31
# File 'lib/lumberg/cpanel/ssl.rb', line 27

def listcsrs(options = {})
  perform_request({
    api_function: "listcsrs",
  }.merge(options))
end

#listkeys(options = {}) ⇒ Object

Public: List SSL keys associated with a domain.

options - Hash options for API call params (default: {}):

Returns Hash API response.



101
102
103
104
105
# File 'lib/lumberg/cpanel/ssl.rb', line 101

def listkeys(options = {})
  perform_request({
    api_function: "listkeys",
  }.merge(options))
end

#listsslitems(options = {}) ⇒ Object

Public: Query for SSL related items installed via cPanel

options - Hash options for API call params (default: {}):

:domains - The domains you wish to query.
:items   - The type of SSL items for which you wish to query.
           Acceptable values include 'key', 'crt', and 'csr'.

Returns Hash API response.



127
128
129
130
131
# File 'lib/lumberg/cpanel/ssl.rb', line 127

def listsslitems(options = {})
  perform_request({
    api_function: "listsslitems",
  }.merge(options))
end

#remove(options = {}) ⇒ Object

Public: Removes a domain's SSL certificate. This function requires access to the 'sslinstall' feature

options - Hash options for API call params (default: {})

domain: String domain corresponding to the SSL certificate
to remove

Returns Hash API response



213
214
215
216
217
# File 'lib/lumberg/cpanel/ssl.rb', line 213

def remove(options = {})
  perform_request({
    api_version: 1, api_function: "delete", response_key: "data"
  }.merge(options))
end

#showcrt(options = {}) ⇒ Object

Public: Print the current cert for a specific host.

options - Hash options for API call params (default: {}):

Returns Hash API response.



74
75
76
77
78
79
80
81
82
83
# File 'lib/lumberg/cpanel/ssl.rb', line 74

def showcrt(options = {})
  perform_request({
    api_function:    "showcrt",
    api_version:     1,
    user:            options[:user],
    response_key:    "data",
    "arg-0"       => options[:domain],
    "arg-1"       => options[:textmode]
  })
end

#showcsr(options = {}) ⇒ Object

Public: Print a specific Certificate Signing Request.

options - Hash options for API call params (default: {}):

:domain   - The name of the domain the CSR was generated for.
:textmode - 0 for human readable, 1 for binary.

Returns Hash API response.



40
41
42
43
44
45
46
47
48
49
# File 'lib/lumberg/cpanel/ssl.rb', line 40

def showcsr(options = {})
  perform_request({
    api_function:    "showcsr",
    api_version:     1,
    user:            options[:user],
    response_key:    "data",
    "arg-0"       => options[:domain],
    "arg-1"       => options[:textmode]
  })
end

#showkey(options = {}) ⇒ Object

Public: Print a key that has already been generated.

options - Hash options for API call params (default: {}):

:domain   - The name of the domain the CSR was generated for.
:textmode - 0 for human readable, 1 for binary.

Returns Hash API response.



58
59
60
61
62
63
64
65
66
67
# File 'lib/lumberg/cpanel/ssl.rb', line 58

def showkey(options = {})
  perform_request({
    api_function:    "showkey",
    api_version:     1,
    user:            options[:user],
    response_key:    "data",
    "arg-0"       => options[:domain],
    "arg-1"       => options[:textmode]
  })
end

#uploadcrt(options = {}) ⇒ Object

Public: Upload an SSL certificate.

options - Hash options for API call params (default: {}):

:crt    - Contents of the SSL certificate

Returns Hash API response.



199
200
201
202
203
# File 'lib/lumberg/cpanel/ssl.rb', line 199

def uploadcrt(options = {})
  perform_request({
    api_function: "uploadcrt",
  }.merge(options))
end