digicert 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.hound.yml +3 -0
- data/.rspec +0 -1
- data/.rubocop.yml +629 -0
- data/.sample.env +4 -0
- data/.sample.pryrc +3 -0
- data/.travis.yml +5 -2
- data/LICENSE.txt +21 -0
- data/README.md +812 -9
- data/bin/console +2 -5
- data/bin/rspec +17 -0
- data/digicert.gemspec +7 -14
- data/lib/digicert.rb +40 -2
- data/lib/digicert/actions.rb +9 -0
- data/lib/digicert/actions/all.rb +27 -0
- data/lib/digicert/actions/base.rb +11 -0
- data/lib/digicert/actions/create.rb +25 -0
- data/lib/digicert/actions/fetch.rb +21 -0
- data/lib/digicert/actions/update.rb +25 -0
- data/lib/digicert/base.rb +35 -0
- data/lib/digicert/base_order.rb +39 -0
- data/lib/digicert/certificate.rb +43 -0
- data/lib/digicert/certificate_downloader.rb +137 -0
- data/lib/digicert/certificate_request.rb +19 -0
- data/lib/digicert/client_certificate/base.rb +17 -0
- data/lib/digicert/client_certificate/digital_signature_plus.rb +13 -0
- data/lib/digicert/client_certificate/email_security_plus.rb +13 -0
- data/lib/digicert/client_certificate/premium.rb +17 -0
- data/lib/digicert/config.rb +21 -0
- data/lib/digicert/configuration.rb +26 -0
- data/lib/digicert/container.rb +35 -0
- data/lib/digicert/container_template.rb +32 -0
- data/lib/digicert/csr_generator.rb +43 -0
- data/lib/digicert/debugger.rb +34 -0
- data/lib/digicert/domain.rb +59 -0
- data/lib/digicert/duplicate_certificate.rb +21 -0
- data/lib/digicert/duplicate_certificate_finder.rb +42 -0
- data/lib/digicert/email_validation.rb +35 -0
- data/lib/digicert/errors.rb +30 -0
- data/lib/digicert/errors/forbidden.rb +9 -0
- data/lib/digicert/errors/request_error.rb +37 -0
- data/lib/digicert/errors/server_error.rb +9 -0
- data/lib/digicert/errors/unauthorized.rb +9 -0
- data/lib/digicert/expiring_order.rb +21 -0
- data/lib/digicert/findable.rb +33 -0
- data/lib/digicert/order.rb +81 -0
- data/lib/digicert/order_cancellation.rb +25 -0
- data/lib/digicert/order_duplicator.rb +11 -0
- data/lib/digicert/order_manager.rb +39 -0
- data/lib/digicert/order_reissuer.rb +11 -0
- data/lib/digicert/organization.rb +43 -0
- data/lib/digicert/product.rb +14 -0
- data/lib/digicert/request.rb +123 -0
- data/lib/digicert/response.rb +30 -0
- data/lib/digicert/ssl_certificate/base.rb +9 -0
- data/lib/digicert/ssl_certificate/ssl_ev_plus.rb +13 -0
- data/lib/digicert/ssl_certificate/ssl_plus.rb +13 -0
- data/lib/digicert/ssl_certificate/ssl_wildcard.rb +13 -0
- data/lib/digicert/version.rb +23 -1
- data/spec/acceptance/certificate_download_spec.rb +68 -0
- data/spec/acceptance/duplicating_certificate_spec.rb +86 -0
- data/spec/acceptance/reissuing_certificate_spec.rb +104 -0
- data/spec/digicert/actions/all_spec.rb +26 -0
- data/spec/digicert/actions/create_spec.rb +47 -0
- data/spec/digicert/actions/fetch_spec.rb +28 -0
- data/spec/digicert/actions/update_spec.rb +39 -0
- data/spec/digicert/certificate_downloader_spec.rb +89 -0
- data/spec/digicert/certificate_request_spec.rb +49 -0
- data/spec/digicert/certificate_spec.rb +93 -0
- data/spec/digicert/client_certificate/digital_signature_plus_spec.rb +32 -0
- data/spec/digicert/client_certificate/email_security_plus_spec.rb +36 -0
- data/spec/digicert/client_certificate/premium_spec.rb +34 -0
- data/spec/digicert/config_spec.rb +39 -0
- data/spec/digicert/container_spec.rb +44 -0
- data/spec/digicert/container_template_spec.rb +32 -0
- data/spec/digicert/csr_generator_spec.rb +31 -0
- data/spec/digicert/domain_spec.rb +89 -0
- data/spec/digicert/duplicate_certificate_finder_spec.rb +27 -0
- data/spec/digicert/duplicate_certificate_spec.rb +15 -0
- data/spec/digicert/email_validation_spec.rb +26 -0
- data/spec/digicert/expiring_order_spec.rb +16 -0
- data/spec/digicert/findable_spec.rb +19 -0
- data/spec/digicert/order_cancellation_spec.rb +24 -0
- data/spec/digicert/order_duplicator_spec.rb +35 -0
- data/spec/digicert/order_reissuer_spec.rb +35 -0
- data/spec/digicert/order_spec.rb +134 -0
- data/spec/digicert/organization_spec.rb +61 -0
- data/spec/digicert/product_spec.rb +28 -0
- data/spec/digicert/request_spec.rb +47 -0
- data/spec/digicert/ssl_certificate/ssl_ev_plus_spec.rb +35 -0
- data/spec/digicert/ssl_certificate/ssl_plus_spec.rb +36 -0
- data/spec/digicert/ssl_certificate/ssl_wildcard_spec.rb +35 -0
- data/spec/fixtures/certificate.pem +79 -0
- data/spec/fixtures/certificate.zip +0 -0
- data/spec/fixtures/certificate_request.json +116 -0
- data/spec/fixtures/certificate_requests.json +59 -0
- data/spec/fixtures/certificate_revoked.json +13 -0
- data/spec/fixtures/container.json +15 -0
- data/spec/fixtures/container_created.json +3 -0
- data/spec/fixtures/container_template.json +15 -0
- data/spec/fixtures/container_templates.json +14 -0
- data/spec/fixtures/containers.json +14 -0
- data/spec/fixtures/domain.json +71 -0
- data/spec/fixtures/domain_created.json +3 -0
- data/spec/fixtures/domains.json +49 -0
- data/spec/fixtures/email_validations.json +17 -0
- data/spec/fixtures/empty.json +0 -0
- data/spec/fixtures/errors.json +6 -0
- data/spec/fixtures/expiring_orders.json +20 -0
- data/spec/fixtures/order.json +107 -0
- data/spec/fixtures/order_created.json +9 -0
- data/spec/fixtures/order_duplicated.json +8 -0
- data/spec/fixtures/order_duplications.json +57 -0
- data/spec/fixtures/order_reissued.json +8 -0
- data/spec/fixtures/orders.json +93 -0
- data/spec/fixtures/organization.json +35 -0
- data/spec/fixtures/organization_created.json +3 -0
- data/spec/fixtures/organizations.json +84 -0
- data/spec/fixtures/ping.json +3 -0
- data/spec/fixtures/product.json +71 -0
- data/spec/fixtures/products.json +100 -0
- data/spec/fixtures/rsa4096.key +51 -0
- data/spec/requests/certificate_duplication_spec.rb +41 -0
- data/spec/requests/certificate_generation_spec.rb +93 -0
- data/spec/requests/certificate_reissuing_spec.rb +38 -0
- data/spec/requests/container_management_spec.rb +36 -0
- data/spec/requests/domain_management_spec.rb +64 -0
- data/spec/requests/order_client_email_security_plus_spec.rb +38 -0
- data/spec/requests/order_management_spec.rb +24 -0
- data/spec/requests/order_ssl_ev_plus_spec.rb +57 -0
- data/spec/requests/order_ssl_wildcard_spec.rb +57 -0
- data/spec/requests/organization_management_spec.rb +22 -0
- data/spec/requests/product_management_spec.rb +24 -0
- data/spec/requests/request_management_spec.rb +24 -0
- data/spec/spec_helper.rb +35 -0
- data/spec/support/fake_digicert_api.rb +324 -0
- metadata +162 -5
data/.sample.env
ADDED
data/.sample.pryrc
ADDED
data/.travis.yml
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Ribose Inc.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,36 +1,839 @@
|
|
1
1
|
# Digicert
|
2
2
|
|
3
|
-
|
3
|
+
[![Build
|
4
|
+
Status](https://travis-ci.org/riboseinc/digicert.svg?branch=master)](https://travis-ci.org/riboseinc/digicert)
|
5
|
+
[![Code
|
6
|
+
Climate](https://codeclimate.com/github/riboseinc/digicert/badges/gpa.svg)](https://codeclimate.com/github/riboseinc/digicert)
|
4
7
|
|
5
|
-
|
8
|
+
The Ruby client for the official Digicert API.
|
6
9
|
|
7
10
|
## Installation
|
8
11
|
|
9
12
|
Add this line to your application's Gemfile:
|
10
13
|
|
11
14
|
```ruby
|
12
|
-
gem
|
15
|
+
gem "digicert"
|
13
16
|
```
|
14
17
|
|
15
18
|
And then execute:
|
16
19
|
|
17
|
-
|
20
|
+
```sh
|
21
|
+
bundle install
|
22
|
+
```
|
18
23
|
|
19
24
|
Or install it yourself as:
|
20
25
|
|
21
|
-
|
26
|
+
```sh
|
27
|
+
gem install digicert
|
28
|
+
```
|
29
|
+
|
30
|
+
## Configure
|
31
|
+
|
32
|
+
Once you have your API key then you can configure it by adding an initializer
|
33
|
+
with the following code
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
Digicert.configure do |config|
|
37
|
+
config.api_key = "SECRET_DEV_API_KEY"
|
38
|
+
|
39
|
+
# Default response type is `object`, but you can configure it if
|
40
|
+
# necessary, and all the further response will be return as config
|
41
|
+
# supported options are `object` and `hash`.
|
42
|
+
#
|
43
|
+
# config.response_type = :object
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
Or
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
Digicert.configuration.api_key = "SECRET_DEV_API_KEY"
|
51
|
+
```
|
22
52
|
|
23
53
|
## Usage
|
24
54
|
|
25
|
-
|
55
|
+
### Container
|
56
|
+
|
57
|
+
Container is an Operational Division used to model your organizational
|
58
|
+
structure. The features of the container you create are determined by
|
59
|
+
its Container Template.
|
60
|
+
|
61
|
+
#### List Containers
|
62
|
+
|
63
|
+
Use this interface to retrieve a list of existing containers.
|
64
|
+
|
65
|
+
Note: This is an undocumented endpoint of the DigiCert Services API.
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
Digicert::Container.all
|
69
|
+
```
|
70
|
+
|
71
|
+
#### Create a Container
|
72
|
+
|
73
|
+
Use this interface to create new container, and this interface also
|
74
|
+
expects us to provide `parent_container` along with the others
|
75
|
+
attributes as `container_id`.
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
Digicert::Container.create(
|
79
|
+
container_id: 123_456_789,
|
80
|
+
template_id: 5,
|
81
|
+
name: "History Department",
|
82
|
+
description: "History, Civ, Ancient Languages",
|
83
|
+
|
84
|
+
user: {
|
85
|
+
first_name: "Awesome",
|
86
|
+
last_name: "User",
|
87
|
+
email: "awesomeuser@example.com",
|
88
|
+
username: "awesomeuser@example.com",
|
89
|
+
access_roles: [{ id: 1 }],
|
90
|
+
},
|
91
|
+
)
|
92
|
+
```
|
93
|
+
|
94
|
+
#### View a Container
|
95
|
+
|
96
|
+
Information about a specific container can be retrieved through this interface,
|
97
|
+
including its name, description, template, and parent container id.
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
Digicert::Container.fetch(container_id)
|
101
|
+
```
|
102
|
+
|
103
|
+
### Container Template
|
104
|
+
|
105
|
+
Container Templates define a set of features that are available to a container.
|
106
|
+
|
107
|
+
#### List Container Templates
|
108
|
+
|
109
|
+
Use this interface to retrieve a list of the templates that are available to use
|
110
|
+
to create child containers.
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
Digicert::ContainerTemplate.all(container_id)
|
114
|
+
```
|
115
|
+
|
116
|
+
#### View a Container Template
|
117
|
+
|
118
|
+
Use this interface to retrieve information about a specific container template,
|
119
|
+
including which user access roles are available under this template.
|
120
|
+
|
121
|
+
```ruby
|
122
|
+
Digicert::ContainerTemplate.fetch(
|
123
|
+
template_id: template_id, container_id: container_id,
|
124
|
+
)
|
125
|
+
```
|
126
|
+
|
127
|
+
### Organization
|
128
|
+
|
129
|
+
#### Create an Organization
|
130
|
+
|
131
|
+
Use this interface to create a new organization. The organization information
|
132
|
+
will be used by DigiCert for validation and may appear on certificates.
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
# Create a new organization
|
136
|
+
# Please pay close attension bellow
|
137
|
+
# on building the organization_attributes
|
138
|
+
#
|
139
|
+
Digicert::Organization.create(organization_attributes)
|
140
|
+
|
141
|
+
# Organization attributes hash
|
142
|
+
#
|
143
|
+
organization_attributes = {
|
144
|
+
name: "digicert, inc.",
|
145
|
+
address: "333 s 520 w",
|
146
|
+
zip: 84042,
|
147
|
+
city: "lindon",
|
148
|
+
state: "utah",
|
149
|
+
country: "us",
|
150
|
+
telephone: 8015551212,
|
151
|
+
container: { id: 17 },
|
152
|
+
|
153
|
+
organization_contact: {
|
154
|
+
first_name: "Some",
|
155
|
+
last_name: "Guy",
|
156
|
+
email: "someguy@digicert.com",
|
157
|
+
telephone: 8015551212,
|
158
|
+
},
|
159
|
+
|
160
|
+
# Optional attributes
|
161
|
+
assumed_name: "DigiCert",
|
162
|
+
address2: "Suite 500",
|
163
|
+
}
|
164
|
+
```
|
165
|
+
|
166
|
+
#### View an Organization
|
167
|
+
|
168
|
+
Use this interface to view information about an organization.
|
169
|
+
|
170
|
+
```ruby
|
171
|
+
Digicert::Organization.fetch(organization_id)
|
172
|
+
```
|
173
|
+
|
174
|
+
#### List all organizations
|
175
|
+
|
176
|
+
Use this interface to retrieve a list of organizations.
|
177
|
+
|
178
|
+
```ruby
|
179
|
+
Digicert::Organization.all
|
180
|
+
```
|
181
|
+
|
182
|
+
### Domain
|
183
|
+
|
184
|
+
#### Create a new Domain
|
185
|
+
|
186
|
+
Use this interface to add a domain for an organization in a container. You must
|
187
|
+
specify at least one validation type for the domain.
|
188
|
+
|
189
|
+
```ruby
|
190
|
+
# Create a new domain in an organization
|
191
|
+
# Please pay close attension in building the attibutes hash
|
192
|
+
#
|
193
|
+
Digicert::Domain.create(domain_attributes)
|
194
|
+
|
195
|
+
# Domain attributes hash
|
196
|
+
#
|
197
|
+
domain_attributes = {
|
198
|
+
name: "digicert.com",
|
199
|
+
organization: { id: 117483 },
|
200
|
+
validations: [
|
201
|
+
{
|
202
|
+
type: "ev",
|
203
|
+
user: { id: 12 }
|
204
|
+
},
|
205
|
+
],
|
206
|
+
|
207
|
+
dcv: { method: "email" },
|
208
|
+
}
|
209
|
+
```
|
210
|
+
|
211
|
+
#### Activate a Domain
|
212
|
+
|
213
|
+
Use this interface to activate a domain that was previously deactivated.
|
214
|
+
|
215
|
+
```ruby
|
216
|
+
domain = Digicert::Domain.find(domain_id)
|
217
|
+
domain.activate
|
218
|
+
```
|
219
|
+
|
220
|
+
#### Deactivate a Domain
|
221
|
+
|
222
|
+
Use this interface to deactivate a domain.
|
223
|
+
|
224
|
+
```ruby
|
225
|
+
domain = Digicert::Domain.find(domain_id)
|
226
|
+
domain.deactivate
|
227
|
+
```
|
228
|
+
|
229
|
+
#### View a Domain
|
230
|
+
|
231
|
+
Use this interface to view a domain, This interface also allows you to pass an
|
232
|
+
additional `hash` to specify if you want to retrieve additional data with the
|
233
|
+
response.
|
234
|
+
|
235
|
+
```ruby
|
236
|
+
Digicert::Domain.fetch(domain_id, include_dcv: true)
|
237
|
+
```
|
238
|
+
|
239
|
+
#### List Domains
|
240
|
+
|
241
|
+
Use this interface to retrieve a list of domains. This interface also supports
|
242
|
+
an additional `filter_params` hash, which can be used to filter the list we want
|
243
|
+
the interface to return.
|
244
|
+
|
245
|
+
```ruby
|
246
|
+
Digicert::Domain.all(filter_params_hash)
|
247
|
+
```
|
248
|
+
|
249
|
+
### Submitting Orders
|
250
|
+
|
251
|
+
#### View Product List
|
252
|
+
|
253
|
+
Use this interface to retrieve a list of available products for an account.
|
254
|
+
|
255
|
+
```ruby
|
256
|
+
Digicert::Product.all
|
257
|
+
```
|
258
|
+
|
259
|
+
#### View Product Details
|
260
|
+
|
261
|
+
Use this interface to retrieve a full set of details for a product.
|
262
|
+
|
263
|
+
```ruby
|
264
|
+
Digicert::Product.fetch(name_id)
|
265
|
+
```
|
266
|
+
|
267
|
+
#### Generate the CSR content
|
268
|
+
|
269
|
+
This interface will allow us to generate the CSR content on the fly, it will
|
270
|
+
return the content that we can use for order creation.
|
271
|
+
|
272
|
+
```ruby
|
273
|
+
Digicert::CSRGenerator.generate(
|
274
|
+
common_name: "example.com",
|
275
|
+
san_names: ["example.com", "www.example.com"],
|
276
|
+
rsa_key: File.read("your_rsa_key_file_path"),
|
277
|
+
organization: Digicert::Organization.first,
|
278
|
+
)
|
279
|
+
```
|
280
|
+
|
281
|
+
#### Create any type of order
|
282
|
+
|
283
|
+
Use this interface to create a new order, this expect two arguments one is
|
284
|
+
`name_id` for the order and another one is the attributes hash.
|
285
|
+
|
286
|
+
```ruby
|
287
|
+
order = Digicert::Order.create(
|
288
|
+
name_id, order_attributes_hash,
|
289
|
+
)
|
290
|
+
|
291
|
+
# Pay close attension building the order attributes
|
292
|
+
# hash, it requries to format the data in a specific
|
293
|
+
# format and once that is satisfied only then it will
|
294
|
+
# perfrom the API operation otherwise it will raise
|
295
|
+
# invalid argument errors.
|
296
|
+
#
|
297
|
+
order_attributes = {
|
298
|
+
certificate: {
|
299
|
+
common_name: "digicert.com",
|
300
|
+
csr: "------ [CSR HERE] ------",
|
301
|
+
signature_hash: "sha256",
|
302
|
+
|
303
|
+
organization_units: ["Developer Operations"],
|
304
|
+
server_platform: { id: 45 },
|
305
|
+
profile_option: "some_ssl_profile",
|
306
|
+
},
|
307
|
+
|
308
|
+
organization: { id: 117483 },
|
309
|
+
validity_years: 3,
|
310
|
+
custom_expiration_date: "2017-05-18",
|
311
|
+
comments: "Comments for the the approver",
|
312
|
+
disable_renewal_notifications: false,
|
313
|
+
renewal_of_order_id: 314152,
|
314
|
+
payment_method: "balance",
|
315
|
+
}
|
316
|
+
```
|
317
|
+
|
318
|
+
The supported value for `name_id` are `ssl_plus`, `ssl_wildcard`, `ssl_ev_plus`,
|
319
|
+
`client_premium`, `email_security_plus` and `digital_signature_plus`. Please
|
320
|
+
check the Digicert documentation for more details on those.
|
321
|
+
|
322
|
+
If you want to create a new order by yourself by following each of the specific
|
323
|
+
class then please check out the interfaces specified bellow.
|
324
|
+
|
325
|
+
#### Order SSL Plus Certificate
|
326
|
+
|
327
|
+
Use this interface to order a SSL Plus Certificate.
|
328
|
+
|
329
|
+
```ruby
|
330
|
+
Digicert::SSLCertificate::SSLPlus.create(
|
331
|
+
certificate: {
|
332
|
+
common_name: "digicert.com",
|
333
|
+
csr: "------ [CSR HERE] ------",
|
334
|
+
signature_hash: "sha256",
|
335
|
+
|
336
|
+
organization_units: ["Developer Operations"],
|
337
|
+
server_platform: { id: 45 },
|
338
|
+
profile_option: "some_ssl_profile",
|
339
|
+
},
|
340
|
+
|
341
|
+
organization: { id: 117483 },
|
342
|
+
validity_years: 3,
|
343
|
+
custom_expiration_date: "2017-05-18",
|
344
|
+
comments: "Comments for the the approver",
|
345
|
+
disable_renewal_notifications: false,
|
346
|
+
renewal_of_order_id: 314152,
|
347
|
+
payment_method: "balance",
|
348
|
+
)
|
349
|
+
```
|
350
|
+
|
351
|
+
#### Order SSL Wildcard Certificate
|
352
|
+
|
353
|
+
Use this interface to order a SSL Wildcard Certificate.
|
354
|
+
|
355
|
+
```ruby
|
356
|
+
Digicert::SSLCertificate::SSLWildcard.create(
|
357
|
+
certificate: {
|
358
|
+
common_name: "digicert.com",
|
359
|
+
csr: "------ [CSR HERE] ------",
|
360
|
+
signature_hash: "sha256",
|
361
|
+
|
362
|
+
organization_units: ["Developer Operations"],
|
363
|
+
server_platform: { id: 45 },
|
364
|
+
profile_option: "some_ssl_profile",
|
365
|
+
},
|
366
|
+
|
367
|
+
organization: { id: 117483 },
|
368
|
+
validity_years: 3,
|
369
|
+
custom_expiration_date: "2017-05-18",
|
370
|
+
comments: "Comments for the the approver",
|
371
|
+
disable_renewal_notifications: false,
|
372
|
+
renewal_of_order_id: 314152,
|
373
|
+
)
|
374
|
+
```
|
375
|
+
|
376
|
+
#### Order SSL EV Plus Certificate
|
377
|
+
|
378
|
+
Use this interface to order a SSL EV Plus Certificate.
|
379
|
+
|
380
|
+
```ruby
|
381
|
+
Digicert::SSLCertificate::SSLEVPlus.create(
|
382
|
+
certificate: {
|
383
|
+
common_name: "digicert.com",
|
384
|
+
csr: "------ [CSR HERE] ------",
|
385
|
+
signature_hash: "sha256",
|
386
|
+
|
387
|
+
organization_units: ["Developer Operations"],
|
388
|
+
server_platform: { id: 45 },
|
389
|
+
profile_option: "some_ssl_profile",
|
390
|
+
},
|
391
|
+
|
392
|
+
organization: { id: 117483 },
|
393
|
+
validity_years: 3,
|
394
|
+
custom_expiration_date: "2017-05-18",
|
395
|
+
comments: "Comments for the the approver",
|
396
|
+
disable_renewal_notifications: false,
|
397
|
+
renewal_of_order_id: 314152,
|
398
|
+
)
|
399
|
+
```
|
400
|
+
|
401
|
+
#### Order Client Premium Certificate
|
402
|
+
|
403
|
+
Use this interface to order a Client Premium Certificate.
|
404
|
+
|
405
|
+
```ruby
|
406
|
+
Digicert::ClientCertificate::Premium.create(
|
407
|
+
certificate: {
|
408
|
+
common_name: "Full Name",
|
409
|
+
emails: ["email@example.com", "email1@example.com"],
|
410
|
+
csr: "------ [CSR HERE] ------",
|
411
|
+
signature_hash: "sha256",
|
412
|
+
|
413
|
+
organization_units: ["Developer Operations"],
|
414
|
+
server_platform: { id: 45 },
|
415
|
+
profile_option: "some_ssl_profile",
|
416
|
+
},
|
417
|
+
|
418
|
+
organization: { id: 117483 },
|
419
|
+
validity_years: 3,
|
420
|
+
custom_expiration_date: "2017-05-18",
|
421
|
+
comments: "Comments for the the approver",
|
422
|
+
disable_renewal_notifications: false,
|
423
|
+
renewal_of_order_id: 314152,
|
424
|
+
)
|
425
|
+
```
|
426
|
+
|
427
|
+
#### Order Email Security Plus
|
428
|
+
|
429
|
+
Use this interface to order a Email Security Plus Certificate
|
430
|
+
|
431
|
+
```ruby
|
432
|
+
Digicert::ClientCertificate::EmailSecurityPlus.create(
|
433
|
+
certificate: {
|
434
|
+
common_name: "Full Name",
|
435
|
+
emails: ["email@example.com", "email1@example.com"],
|
436
|
+
signature_hash: "sha256",
|
437
|
+
|
438
|
+
organization_units: ["Developer Operations"],
|
439
|
+
server_platform: { id: 45 },
|
440
|
+
profile_option: "some_ssl_profile",
|
441
|
+
},
|
442
|
+
|
443
|
+
organization: { id: 117483 },
|
444
|
+
validity_years: 3,
|
445
|
+
auto_renew: 10,
|
446
|
+
renewal_of_order_id: 314152,
|
447
|
+
)
|
448
|
+
```
|
449
|
+
|
450
|
+
#### Order Client Digital Signature Plus
|
451
|
+
|
452
|
+
Use this interface to order a Client Digital Signature Plus
|
453
|
+
|
454
|
+
```ruby
|
455
|
+
Digicert::Order::DigitalSignaturePlus.create(
|
456
|
+
certificate: {
|
457
|
+
common_name: "Full Name",
|
458
|
+
emails: ["email@example.com", "email1@example.com"],
|
459
|
+
csr: "-----BEGIN CERTIFICATE REQUEST----- ...",
|
460
|
+
signature_hash: "sha256",
|
461
|
+
},
|
462
|
+
|
463
|
+
organization: { id: 117483 },
|
464
|
+
validity_years: 3,
|
465
|
+
auto_renew: 10,
|
466
|
+
renewal_of_order_id: 314152,
|
467
|
+
)
|
468
|
+
```
|
469
|
+
|
470
|
+
### Request Management
|
471
|
+
|
472
|
+
#### List certificate requests
|
473
|
+
|
474
|
+
Use this interface to retrieve a list of certificate requests.
|
475
|
+
|
476
|
+
```ruby
|
477
|
+
Digicert::CertificateRequest.all
|
478
|
+
```
|
479
|
+
|
480
|
+
#### Certificate Request details
|
481
|
+
|
482
|
+
Use this interface to retrieve the details for a certificate request.
|
483
|
+
|
484
|
+
```ruby
|
485
|
+
Digicert::CertificateRequest.fetch(request_id)
|
486
|
+
```
|
487
|
+
|
488
|
+
#### Update Request Status
|
489
|
+
|
490
|
+
Use this interface to update the status of a previously submitted certificate
|
491
|
+
request.
|
492
|
+
|
493
|
+
```ruby
|
494
|
+
Digicert::CertificateRequest.update(
|
495
|
+
request_id, status: "approved", processor_comment: "Your domain is approved",
|
496
|
+
)
|
497
|
+
```
|
498
|
+
|
499
|
+
### Order Management
|
500
|
+
|
501
|
+
#### View a Certificate Order
|
502
|
+
|
503
|
+
Use this interface to retrieve a certificate order and the response includes all
|
504
|
+
the order attributes along with a `certificate` in it.
|
505
|
+
|
506
|
+
```ruby
|
507
|
+
Digicert::Order.fetch(order_id)
|
508
|
+
```
|
509
|
+
|
510
|
+
#### List Certificate Orders
|
511
|
+
|
512
|
+
Use this interface to retrieve a list of all certificate orders.
|
513
|
+
|
514
|
+
```ruby
|
515
|
+
Digicert::Order.all
|
516
|
+
```
|
517
|
+
|
518
|
+
#### List of Email Validations
|
519
|
+
|
520
|
+
Use this interface to view the status of all emails that require validation on a
|
521
|
+
client certificate order.
|
522
|
+
|
523
|
+
```ruby
|
524
|
+
Digicert::EmailValidation.all(order_id: order_id)
|
525
|
+
|
526
|
+
# If you prefer then there is an alternative alias method
|
527
|
+
# on the order class, you can invoke that on any of its
|
528
|
+
# instances. Usages
|
529
|
+
#
|
530
|
+
order = Digicert::Order.find(order_id)
|
531
|
+
order.email_validations
|
532
|
+
```
|
533
|
+
|
534
|
+
#### Validate an Email Address
|
535
|
+
|
536
|
+
Use this interface to verify control of an email address, using an email
|
537
|
+
address/token pair.
|
538
|
+
|
539
|
+
```ruby
|
540
|
+
Digicert::EmailValidation.valid?(token: token, email: email)
|
541
|
+
# => true or false
|
542
|
+
```
|
543
|
+
|
544
|
+
#### Reissue a Certificate Order
|
545
|
+
|
546
|
+
Use this interface to reissue a certificate order. A reissue replaces the
|
547
|
+
existing certificate with a new one that has different information such as
|
548
|
+
common name, CSR, etc. The simplest interface to reissue an update an existing
|
549
|
+
order is
|
550
|
+
|
551
|
+
```ruby
|
552
|
+
order = Digicert::Order.find(order_id)
|
553
|
+
order.reissue
|
554
|
+
|
555
|
+
# Alternative and prefereed in most case
|
556
|
+
Digicert::OrderReissuer.create(order_id: order_id)
|
557
|
+
```
|
558
|
+
|
559
|
+
And if there are some updated information like `csr`, `common_name` or etc then
|
560
|
+
you can use the same interface but pass the `:certificate` option. Please
|
561
|
+
remember if any required fields are missing then it will use the data that
|
562
|
+
already exists for that order.
|
563
|
+
|
564
|
+
```ruby
|
565
|
+
Digicert::OrderReissuer.create(
|
566
|
+
order: order_id,
|
567
|
+
certificate: {
|
568
|
+
common_name: certificate_common_name,
|
569
|
+
dns_names: [certificate_dns_name],
|
570
|
+
csr: certificate_csr,
|
571
|
+
signature_hash: certificate_signature_hash,
|
572
|
+
server_platform: { id: certificate_server_platform_id },
|
573
|
+
}
|
574
|
+
)
|
575
|
+
```
|
576
|
+
|
577
|
+
#### Duplicate a Certificate Order
|
578
|
+
|
579
|
+
Use this interface to request a duplicate certificate for an order. A duplicate
|
580
|
+
shares the expiration date as the existing certificate and is identical with the
|
581
|
+
exception of the CSR and a possible change in the server platform and signature
|
582
|
+
hash. The common name and sans need to be the same as the original order.
|
583
|
+
|
584
|
+
```ruby
|
585
|
+
Digicert::OrderDuplicator.create(
|
586
|
+
order: order_id,
|
587
|
+
certificate: {
|
588
|
+
common_name: certificate_common_name,
|
589
|
+
dns_names: [certificate_dns_name],
|
590
|
+
csr: certificate_csr,
|
591
|
+
signature_hash: certificate_signature_hash,
|
592
|
+
server_platform: { id: certificate_server_platform_id },
|
593
|
+
}
|
594
|
+
)
|
595
|
+
```
|
596
|
+
|
597
|
+
#### Find a Duplicate Certificate
|
598
|
+
|
599
|
+
As of now, the Digicert API, does not have an easier way to find a duplicate
|
600
|
+
certificate, as the certificate duplication returns existing `order_id` with a
|
601
|
+
`request` node which only has an `id`.
|
602
|
+
|
603
|
+
So to find out a duplicate certificate, we need to retrieve the details for that
|
604
|
+
specific request and from that response retrieve the `date_created` for the
|
605
|
+
duplicate certificate and then use that `date_created` to find out the correct
|
606
|
+
certificate from the duplications of that specific order.
|
607
|
+
|
608
|
+
This requires lots of work, so this following interface will do all of its
|
609
|
+
underlying tasks, and all we need to do is pass the requests id that we will
|
610
|
+
have form the certificate duplication.
|
611
|
+
|
612
|
+
```ruby
|
613
|
+
# Duplicate an existing certificate order
|
614
|
+
#
|
615
|
+
order = Digicert::Order.find(order_id)
|
616
|
+
duplicate_order = order.duplicate
|
617
|
+
|
618
|
+
# Use the request id to find out the certificate
|
619
|
+
#
|
620
|
+
request_id = duplicate_order.requests.first.id
|
621
|
+
Digicert::DuplicateCertificateFinder.find_by(request_id: request_id)
|
622
|
+
```
|
623
|
+
|
624
|
+
#### List Duplicate Certificates
|
625
|
+
|
626
|
+
Use this interface to view all duplicate certificates for an order.
|
627
|
+
|
628
|
+
```ruby
|
629
|
+
Digicert::DuplicateCertificate.all(order_id: order_id)
|
630
|
+
|
631
|
+
# Alternative interface for duplicate certificates
|
632
|
+
order = Digicert::Order.find(order_id)
|
633
|
+
order.duplicate_certificates
|
634
|
+
```
|
635
|
+
|
636
|
+
#### Cancel a Certificate Order
|
637
|
+
|
638
|
+
Use this interface to update the status of an order. Currently this endpoint only
|
639
|
+
allows updating the status to 'CANCELED'
|
640
|
+
|
641
|
+
```ruby
|
642
|
+
order = Digicert::Order.find(order_id)
|
643
|
+
order.cancel(note: "Cancellation note")
|
644
|
+
|
645
|
+
# Or use the actual interface for more control
|
646
|
+
Digicert::OrderCancellation.create(
|
647
|
+
order_id: order_id, status: "CANCELED", note: "your_note", send_emails: true,
|
648
|
+
)
|
649
|
+
```
|
650
|
+
|
651
|
+
### Reports
|
652
|
+
|
653
|
+
#### Expiring Orders
|
654
|
+
|
655
|
+
Use this interface to retrieve the number of orders that have certificates
|
656
|
+
expiring within 90, 60, and 30 days. The number of orders that have already
|
657
|
+
expired certificates within the last 7 days is also returned.
|
658
|
+
|
659
|
+
```ruby
|
660
|
+
Digicert::ExpiringOrder.all(container_id: container_id)
|
661
|
+
```
|
662
|
+
|
663
|
+
### Certificate Management
|
664
|
+
|
665
|
+
#### Download a Certificate
|
666
|
+
|
667
|
+
This request will return an SSL Certificate file from an order. By default, it
|
668
|
+
uses the platform specified by the order.
|
669
|
+
|
670
|
+
```ruby
|
671
|
+
# Fetch the certficate details that includes a http status code
|
672
|
+
# and the file content in the `#body`, so you can choose if you
|
673
|
+
# want to write it to your filesystem or directly upload it to
|
674
|
+
# your host, and the contents it returns is `zip` archieve.
|
675
|
+
#
|
676
|
+
certificate = Digicert::CertificateDownloader.fetch(certificate_id, **attributes)
|
677
|
+
|
678
|
+
# write to content to somewhere in your filesystem.
|
679
|
+
#
|
680
|
+
File.write("path_to_file_system/certificate.zip", certificate.body)
|
681
|
+
|
682
|
+
# Alaternative to fetch it through certificate instance
|
683
|
+
#
|
684
|
+
certificate = Digicert::Certificate.find(certificate_id)
|
685
|
+
certificate_content_object = certificate.download
|
686
|
+
```
|
687
|
+
|
688
|
+
Additionally, if you want the gem to handle the file writing then it also
|
689
|
+
provides another helper interface `fetch_to_path`, and that will fetch the file
|
690
|
+
content and write the content to supplied path.
|
691
|
+
|
692
|
+
```ruby
|
693
|
+
Digicert::CertificateDownloader.fetch_to_path(
|
694
|
+
certificate_id,
|
695
|
+
ext: "zip",
|
696
|
+
path: File.expand_path("./file/download/path"),
|
697
|
+
**other_attributes_hash_like_platform_or_format,
|
698
|
+
)
|
699
|
+
|
700
|
+
# Alternative through a certificate instance
|
701
|
+
#
|
702
|
+
certificate = Digicert::Certificate.find(certificate_id)
|
703
|
+
certificate.download_to_path(path: "file/path", ext: "zip", format: "zip")
|
704
|
+
```
|
705
|
+
|
706
|
+
#### Download a Certificate By Format
|
707
|
+
|
708
|
+
This interface will return an SSL Certificate file from an order. The certificate
|
709
|
+
will be return in the format you specify, but one thing to remember the
|
710
|
+
certificate will be archived as `zip` along with the instructions, so you need
|
711
|
+
to write that as zip archive.
|
712
|
+
|
713
|
+
```ruby
|
714
|
+
Digicert::CertificateDownloader.fetch_by_format(
|
715
|
+
certificate_id, format: format,
|
716
|
+
)
|
717
|
+
|
718
|
+
# Alternative using the certificate instance
|
719
|
+
#
|
720
|
+
certificate = Digicert::Certificate.find(certificate_id)
|
721
|
+
certificate_content_object = certificate.download(format: format)
|
722
|
+
```
|
723
|
+
|
724
|
+
#### Download a Certificate By Platform
|
725
|
+
|
726
|
+
This interface will return an SSL Certificate file from an order using the
|
727
|
+
platform specified.
|
728
|
+
|
729
|
+
```ruby
|
730
|
+
certificate = Digicert::CertificateDownloader.fetch_by_platform(
|
731
|
+
certificate_id, platform: "apache",
|
732
|
+
)
|
733
|
+
|
734
|
+
# Alternative using the certificate instance
|
735
|
+
#
|
736
|
+
certificate = Digicert::Certificate.find(certificate_id)
|
737
|
+
certificate_content_object = certificate.download(platform: "apache")
|
738
|
+
```
|
739
|
+
|
740
|
+
#### Download a Certificate content
|
741
|
+
|
742
|
+
This interface will fetch a SSL Certificate and extract all of its subsidiary
|
743
|
+
certificates content and return as a hash with `certificate`, `root_certificate`
|
744
|
+
and `intermediate_certificate` keys.
|
745
|
+
|
746
|
+
```ruby
|
747
|
+
Digicert::CertificateDownloader.fetch_content(certificate_id)
|
748
|
+
|
749
|
+
# Alternative using certificate instance
|
750
|
+
#
|
751
|
+
certificate = Digicert::Certificate.find(certificate_id)
|
752
|
+
certificate.download_content
|
753
|
+
```
|
754
|
+
|
755
|
+
#### Revoke a Certificate
|
756
|
+
|
757
|
+
This interface will revoke a previously issued SSL Certificate.
|
758
|
+
|
759
|
+
```ruby
|
760
|
+
Digicert::Certificate.revoke(certificate_id, comments: "Your comment")
|
761
|
+
```
|
26
762
|
|
27
763
|
## Development
|
28
764
|
|
29
|
-
|
765
|
+
We are following Sandi Metz's Rules for this gem, you can read the
|
766
|
+
[description of the rules here][sandi-metz] All new code should follow these
|
767
|
+
rules. If you make changes in a pre-existing file that violates these rules you
|
768
|
+
should fix the violations as part of your contribution.
|
769
|
+
|
770
|
+
### Setup
|
771
|
+
|
772
|
+
Clone the repository.
|
773
|
+
|
774
|
+
```sh
|
775
|
+
git clone https://github.com/riboseinc/digicert
|
776
|
+
```
|
30
777
|
|
31
|
-
|
778
|
+
Setup your environment.
|
779
|
+
|
780
|
+
```sh
|
781
|
+
bin/setup
|
782
|
+
```
|
783
|
+
|
784
|
+
Run the test suite
|
785
|
+
|
786
|
+
```sh
|
787
|
+
bin/rspec
|
788
|
+
```
|
789
|
+
|
790
|
+
### Play Box
|
791
|
+
|
792
|
+
The API Play Box provides an interactive console so we can easily test out the
|
793
|
+
actual API interaction. But before moving forward let's configure the your key.
|
794
|
+
|
795
|
+
Setup the client configuration.
|
796
|
+
|
797
|
+
```sh
|
798
|
+
cp .sample.pryrc .pryrc
|
799
|
+
vim .pryrc
|
800
|
+
```
|
801
|
+
|
802
|
+
Start the console.
|
803
|
+
|
804
|
+
```sh
|
805
|
+
bin/console
|
806
|
+
```
|
807
|
+
|
808
|
+
Start playing with it.
|
809
|
+
|
810
|
+
```ruby
|
811
|
+
Digicert::Product.all
|
812
|
+
```
|
32
813
|
|
33
814
|
## Contributing
|
34
815
|
|
35
|
-
|
816
|
+
First, thank you for contributing! We love pull requests from everyone. By
|
817
|
+
participating in this project, you hereby grant [Ribose Inc.][riboseinc] the
|
818
|
+
right to grant or transfer an unlimited number of non exclusive licenses or
|
819
|
+
sub-licenses to third parties, under the copyright covering the contribution
|
820
|
+
to use the contribution by all means.
|
821
|
+
|
822
|
+
Here are a few technical guidelines to follow:
|
823
|
+
|
824
|
+
1. Open an [issue][issues] to discuss a new feature.
|
825
|
+
1. Write tests to support your new feature.
|
826
|
+
1. Make sure the entire test suite passes locally and on CI.
|
827
|
+
1. Open a Pull Request.
|
828
|
+
1. [Squash your commits][squash] after receiving feedback.
|
829
|
+
1. Party!
|
830
|
+
|
831
|
+
|
832
|
+
## Credits
|
833
|
+
|
834
|
+
This gem is developed, maintained and funded by [Ribose Inc.][riboseinc]
|
36
835
|
|
836
|
+
[riboseinc]: https://www.ribose.com
|
837
|
+
[issues]: https://github.com/riboseinc/digicert/issues
|
838
|
+
[squash]: https://github.com/thoughtbot/guides/tree/master/protocol/git#write-a-feature
|
839
|
+
[sandi-metz]: http://robots.thoughtbot.com/post/50655960596/sandi-metz-rules-for-developers
|