Class: DNSimple::Certificate
Overview
Represents an SSL certificate that has been purchased.
The certificate must also be submitted using the #submit method before the Certificate Authority will issue a signed certificate.
Instance Attribute Summary collapse
-
#approver_email ⇒ Object
The approver email address.
-
#available_approver_emails ⇒ Object
An array of all emails that can be used to approve the certificate.
-
#certificate_status ⇒ Object
The Certificate status.
-
#created_at ⇒ Object
When the certificate was purchased.
-
#csr ⇒ Object
The Certificate Signing Request.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#expiration_date ⇒ Object
The date the Certificate will expire.
-
#id ⇒ Object
The certificate ID in DNSimple.
-
#name ⇒ Object
The subdomain on the certificate.
-
#order_date ⇒ Object
The date the Certificate order was placed.
-
#private_key ⇒ Object
The private key, if DNSimple generated the Certificate Signing Request.
-
#ssl_certificate ⇒ Object
The SSL certificate, if it has been issued by the Certificate Authority.
-
#updated_at ⇒ Object
When the certificate was last updated.
Class Method Summary collapse
-
.all(domain, options = {}) ⇒ Object
Get an array of all certificates for the given domain.
-
.find(domain, id, options = {}) ⇒ Object
Find a specific certificate for the given domain.
-
.purchase(domain, name, contact, options = {}) ⇒ Object
Purchase a certificate under the given domain with the given name.
Instance Method Summary collapse
-
#fqdn ⇒ Object
Get the fully-qualified domain name for the certificate.
- #submit(approver_email, options = {}) ⇒ Object
Methods inherited from Base
Constructor Details
This class inherits a constructor from DNSimple::Base
Instance Attribute Details
#approver_email ⇒ Object
The approver email address
27 28 29 |
# File 'lib/dnsimple/certificate.rb', line 27 def approver_email @approver_email end |
#available_approver_emails ⇒ Object
An array of all emails that can be used to approve the certificate
36 37 38 |
# File 'lib/dnsimple/certificate.rb', line 36 def available_approver_emails @available_approver_emails end |
#certificate_status ⇒ Object
The Certificate status
39 40 41 |
# File 'lib/dnsimple/certificate.rb', line 39 def certificate_status @certificate_status end |
#created_at ⇒ Object
When the certificate was purchased
30 31 32 |
# File 'lib/dnsimple/certificate.rb', line 30 def created_at @created_at end |
#csr ⇒ Object
The Certificate Signing Request
18 19 20 |
# File 'lib/dnsimple/certificate.rb', line 18 def csr @csr end |
#domain ⇒ Object
Returns the value of attribute domain.
12 13 14 |
# File 'lib/dnsimple/certificate.rb', line 12 def domain @domain end |
#expiration_date ⇒ Object
The date the Certificate will expire
45 46 47 |
# File 'lib/dnsimple/certificate.rb', line 45 def expiration_date @expiration_date end |
#id ⇒ Object
The certificate ID in DNSimple
10 11 12 |
# File 'lib/dnsimple/certificate.rb', line 10 def id @id end |
#name ⇒ Object
The subdomain on the certificate
15 16 17 |
# File 'lib/dnsimple/certificate.rb', line 15 def name @name end |
#order_date ⇒ Object
The date the Certificate order was placed
42 43 44 |
# File 'lib/dnsimple/certificate.rb', line 42 def order_date @order_date end |
#private_key ⇒ Object
The private key, if DNSimple generated the Certificate Signing Request
24 25 26 |
# File 'lib/dnsimple/certificate.rb', line 24 def private_key @private_key end |
#ssl_certificate ⇒ Object
The SSL certificate, if it has been issued by the Certificate Authority
21 22 23 |
# File 'lib/dnsimple/certificate.rb', line 21 def ssl_certificate @ssl_certificate end |
#updated_at ⇒ Object
When the certificate was last updated
33 34 35 |
# File 'lib/dnsimple/certificate.rb', line 33 def updated_at @updated_at end |
Class Method Details
.all(domain, options = {}) ⇒ Object
Get an array of all certificates for the given domain.
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/dnsimple/certificate.rb', line 81 def self.all(domain, ={}) response = DNSimple::Client.get("/v1/domains/#{domain.name}/certificates", ) case response.code when 200 response.map { |r| new({:domain => domain}.merge(r["certificate"])) } else raise RequestError.new("Error listing certificates", response) end end |
.find(domain, id, options = {}) ⇒ Object
Find a specific certificate for the given domain.
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/dnsimple/certificate.rb', line 93 def self.find(domain, id, = {}) response = DNSimple::Client.get("/v1/domains/#{domain.name}/certificates/#{id}", ) case response.code when 200 new({:domain => domain}.merge(response["certificate"])) when 404 raise RecordNotFound, "Could not find certificate #{id} for domain #{domain.name}" else raise RequestError.new("Error finding certificate", response) end end |
.purchase(domain, name, contact, options = {}) ⇒ Object
Purchase a certificate under the given domain with the given name. The name will be appended to the domain name, and thus should only be the subdomain part.
Example: DNSimple::Certificate.purchase(domain, âwwwâ, contact)
Please note that by invoking this method DNSimple will immediately charge your credit card on file at DNSimple for the full certificate price.
For wildcard certificates an asterisk must appear in the name.
Example: DNSimple::Certificate.purchase(domain, â*â, contact)
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/dnsimple/certificate.rb', line 60 def self.purchase(domain, name, contact, ={}) certificate_hash = { :name => name, :contact_id => contact.id } .merge!({:body => {:certificate => certificate_hash}}) response = DNSimple::Client.post("/v1/domains/#{domain.name}/certificates", ) case response.code when 201 new({ :domain => domain }.merge(response["certificate"])) when 406 raise RecordExists, "Certificate for #{domain.name} already exists" else raise RequestError.new("Error purchasing certificate", response) end end |
Instance Method Details
#fqdn ⇒ Object
Get the fully-qualified domain name for the certificate. This is the domain.name joined with the certificate name, separated by a period.
109 110 111 |
# File 'lib/dnsimple/certificate.rb', line 109 def fqdn [name, domain.name].delete_if { |p| p !~ DNSimple::BLANK_REGEX }.join(".") end |
#submit(approver_email, options = {}) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/dnsimple/certificate.rb', line 113 def submit(approver_email, ={}) raise DNSimple::Error, "Approver email is required" unless approver_email .merge!(:body => {:certificate => {:approver_email => approver_email}}) response = DNSimple::Client.put("/v1/domains/#{domain.name}/certificates/#{id}/submit", ) case response.code when 200 Certificate.new({ :domain => domain }.merge(response["certificate"])) else raise RequestError.new("Error submitting certificate", response) end end |