globessl 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ab974923f3b0558a6f625a7d86ff758e2c408a10
4
+ data.tar.gz: e284db82556815a2c109ea76e2c097c281a7922e
5
+ SHA512:
6
+ metadata.gz: 534a65cec8f591f3c5748aff65c09845850910b5a4bd5b4d330a7b797518f96e94293e026ae2f4ae49ccc3a256d9768776fb88957d16c86ff8ed4118b3448c9b
7
+ data.tar.gz: 40bb403c130064d99027308adfadb1e63d58b392ac1b2c19c5981a133e91c050e79c8d4e7cfaacfbebea3ad25f98fa27daa35ac8f9fd49926eafa470b93614bd
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ .bundle/
3
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ #gem 'byebug', group: [:development, :test]
4
+
5
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2015 Brightcommerce, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,383 @@
1
+ # GlobeSSL Client
2
+ The **GlobeSSL Client** is a Ruby API client for GlobeSSL CA resellers. This client provides almost all of the functionality exposed by version 2 of their API. To use this client you will need an API key.
3
+
4
+ ## Background
5
+ The **GlobeSSL Client** is an opinionated client library for the GlobeSSL CA API. We built this library to provide fully automated provisioning of SSL Certificates for our client's apps and websites using the Brightcommerce API.
6
+
7
+ The **GlobeSSL Client** provides endpoint access to the API methods that fulfill our requirements. It is very important to us that integration with GlobeSSL CA is seamless and provides as few touch-points as possible with the end-user. For instance, for the domain validation method we use the 'http' method which permits us to prove ownership of a domain by providing a specific text file at a specific URL. This means the end-user doesn't have to click a link in an email and punch in a code to validate ownership of a domain. We also use their autocsr method to generate the Certificate Signing Request and Private Key, rather than shell out and use OpenSSL.
8
+
9
+ The **GlobeSSL Client** has undergone extensive real-world testing with real certificates. We worked closely with the CTO from GlobeSSL CA to address any issues or suggestions we had with their API. The assistance we received was truly excellent, and we're happy to provide this library to the public domain, which we hope will only mean more resellers for them.
10
+
11
+ ## About GlobeSSL CA
12
+ To find out more about GlobeSSL CA please visit their [website](https://www.globessl.com). You can find out more about the API by reading their [documentation](https://api.globessl.com/docs/). To use their API you need to have a reseller account, you can find out more about their reseller plans at the [strategic partners](https://www.globessl.com/strategic-partners/) page on their website.
13
+
14
+ ## Installation
15
+ To install add the line to your `Gemfile`:
16
+ ```bash
17
+ gem 'globessl'
18
+ ```
19
+ And call `bundle install`.
20
+
21
+ Alternatively, you can install it from the terminal:
22
+ ```bash
23
+ gem install globessl
24
+ ```
25
+
26
+ ## Dependencies
27
+ **GlobeSSL Client** has the following runtime dependencies:
28
+ - Virtus ~> 1.0.3
29
+
30
+ ## Compatibility
31
+ Developed with MRI 2.2, however the `.clientspec` only specifies MRI 2.0. It may work with other flavors, but it hasn't been tested. Please let us know if you encounter any issues.
32
+
33
+ ## How To Use
34
+
35
+ ### Prerequisites
36
+ **GlobeSSL Client** requires an API key. By default the library will look for your API key in the environment variable `GLOBESSL_API_KEY`. If you'd like to override this and provide the API key directly to the API, setup a configuration initializer as shown below:
37
+ ```ruby
38
+ GlobeSSL.configure do |config|
39
+ config.api_key = "b04b4e74c57c37de48863ef9373963e0b496f5e7" # fictional
40
+ end
41
+ ```
42
+
43
+ You can access any configuration settings directly on the GlobeSSL namespace:
44
+ ```ruby
45
+ api_key = GlobeSSL.api_key #=> b04b4e74c57c37de48863ef9373963e0b496f5e7
46
+ api_url = GlobeSSL.api_url #=> https://api.globessl.com/v2
47
+ ```
48
+
49
+ ### API Calls
50
+ The **GlobeSSL Client** provides access to the following GlobeSSL CA API endpoints:
51
+ - [account/balance](https://api.globessl.com/docs/#api-account-balance) Retrieves your reseller account balance.
52
+ - [account/details](https://api.globessl.com/docs/#api-account-details) Retrieves your reseller account details.
53
+ - [products/list](https://api.globessl.com/docs/#api-products-list) Returns a detailed list of all available SSL Certificate products.
54
+ - [products/details](https://api.globessl.com/docs/#api-products-details) Returns single product's details.
55
+ - [tools/webservers](https://api.globessl.com/docs/#api-tools-webservers) Returns an array with available web server types.
56
+ - [tools/domainemails](https://api.globessl.com/docs/#api-tools-getdomainemails) Returns an array with available domain validation email addresses.
57
+ - [tools/autocsr](https://api.globessl.com/docs/#api-tools-autocsr) Returns a private key and certificate signing request.
58
+ - [tools/decodecsr](https://api.globessl.com/docs/#api-tools-decodescr) Validates submitted CSR code. Returns parsed data in array.
59
+ - [order/ssl](https://api.globessl.com/docs/#api-order-ssl) Order a new SSL Certificate.
60
+ - [certificates/get](https://api.globessl.com/docs/#api-certificates-get) Retrieve a single SSL Certificate.
61
+ - [certificates/reissue](https://api.globessl.com/docs/#api-certificates-reissue) Reissue a single certificate.
62
+ - [dcv/change](https://api.globessl.com/docs/#api-dcv-change) Change DCV Method for SSL Certificate.
63
+ - [dcv/resend](https://api.globessl.com/docs/#api-dcv-resend) Re-sends validation email for the SSL Certificate.
64
+
65
+ **GlobeSSL Client** does not provide access the following GlobeSSL CA API endpoint:
66
+ - [order/quick](https://api.globessl.com/docs/#api-order-quickssl) Order a new SSL Certificate using invite method. The client will receive the URL for completing the SSL generation.
67
+
68
+ ## How To Use
69
+ We've attempted to make the **GlobeSSL Client** interface as consistent as possible. The GlobeSSL CA API has the following rules:
70
+ - `GET` requests require any parameters in the URL.
71
+ - `POST` requests require any parameters as `x-www-form-urlencoded` and passed in the request body.
72
+ - The resellers API key is passed in the `X-API-KEY` header.
73
+ - All responses including errors are returned in the `body` and are encoded as `JSON`.
74
+
75
+ The **GlobeSSL Client** breaks the API into consistent logical domain models. The models are backed by Virtus Model and most provide a `#fetch` method. Where a model performs a specific action the method will be named, and the parameters for the model must be provided as attributes on the class. Every call performs some validation before executing the API call. If the validation fails, the call will return `false` and any exceptions are made available in the `#errors` collection attribute.
76
+
77
+ Following are examples of how to instantiate each class with attributes where necessary, and the properties that can be queried on the class after each API call. All example information including names, addresses and other details are completely fictional and provided to give context.
78
+
79
+ ### Account Balance
80
+ ```ruby
81
+ @account = GlobeSSL::AccountBalance.new
82
+
83
+ result = @account.fetch #=> true
84
+
85
+ # If the fetch method fails it will return false and populate the errors collection attribute:
86
+ if result == false
87
+ @account.errors.each do |err|
88
+ puts err
89
+ end
90
+ end
91
+
92
+ # AccountBalance properties
93
+ @account.balance #=> 1234.56
94
+ @account.currency #=> 'USD'
95
+ ```
96
+
97
+ ### Account Details
98
+ ```ruby
99
+ @account = GlobeSSL::AccountDetails.new
100
+
101
+ result = @account.fetch #=> true
102
+
103
+ # If the fetch method fails it will return false and populate the errors collection attribute:
104
+ if result == false
105
+ @account.errors.each do |err|
106
+ puts err
107
+ end
108
+ end
109
+
110
+ # AccountDetails properties
111
+ @account.account_id #=> 9999
112
+ @account.balance #=> 1234.56
113
+ @account.total_balance #=> 1234.56
114
+ @account.account_type #=> 29
115
+ @account.email #=> support@acmecerts.com
116
+ @account.name #=> Richard Reseller
117
+ @account.company #=> Acme SSL Certs
118
+ @account.address #=> 123 Fourth Street
119
+ @account.city #=> Fivetown
120
+ @account.state # South Sixly
121
+ @account.country # US
122
+ @account.postal_code #=> 12345-6789
123
+ ```
124
+
125
+ ### Products
126
+ ```ruby
127
+ @products = GlobeSSL::Products.new
128
+
129
+ result = @products.fetch #=> true
130
+
131
+ # If the fetch method fails it will return false and populate the errors collection attribute:
132
+ if result == false
133
+ @products.errors.each do |err|
134
+ puts err
135
+ end
136
+ end
137
+
138
+ @products.list #=> an enumerable array of GlobeSSL::Product
139
+ @products.list.size #=> 39
140
+
141
+ # Enumerate each
142
+ @products.list.each do |prod|
143
+ puts prod.name
144
+ end
145
+
146
+ # Product properties
147
+ prod = @products.list.first
148
+ prod.is_a?(GlobeSSL::Product) #=> true
149
+ prod.id #=> 106
150
+ prod.name #=> Globe FREE SSL
151
+ prod.validation #=> dv
152
+ prod.wildcard #=> false
153
+ prod.mdc #=> false
154
+ prod.mdc_min #=> 0
155
+ prod.mdc_max #=> 0
156
+ prod.brand #=> Globe SSL
157
+
158
+ # You can also request a single product like so:
159
+ @product = GlobeSSL::Product.new(:id => 106)
160
+ result = @product.fetch #=> true
161
+ @product.is_a?(GlobeSSL::Product) #=> true
162
+
163
+ # If the fetch method fails it will return false and populate the errors collection attribute:
164
+ if result == false
165
+ @product.errors.each do |err|
166
+ puts err
167
+ end
168
+ end
169
+ ```
170
+
171
+ ### Webservers
172
+ ```ruby
173
+ @webservers = GlobeSSL::Webservers.new
174
+
175
+ result = @webservers.fetch #=> true
176
+
177
+ # If the fetch method fails it will return false and populate the errors collection attribute:
178
+ if result == false
179
+ @webservers.errors.each do |err|
180
+ puts err
181
+ end
182
+ end
183
+
184
+ @webservers.list #=> an enumerable array of GlobeSSL::Webserver
185
+ @webservers.list.size #=> 37
186
+
187
+ # Enumerate each
188
+ @webservers.list.each do |ws|
189
+ puts "#{ws.id.to_s}: #{ws.name}"
190
+ end
191
+
192
+ # Webserver properties
193
+ webserver = @webservers.list.first
194
+ webserver.is_a?(GlobeSSL::Webserver) #=> true
195
+ webserver.id #=> 1
196
+ webserver.name #=> AOL
197
+ ```
198
+
199
+ ### Domain Emails
200
+ ```ruby
201
+ @domain_emails = GlobeSSL::DomainEmails.new(:domain => "acmecerts.com")
202
+
203
+ result = @domain_emails.fetch #=> true
204
+
205
+ # If the fetch method fails it will return false and populate the errors collection attribute:
206
+ if result == false
207
+ @domain_emails.errors.each do |err|
208
+ puts err
209
+ end
210
+ end
211
+
212
+ @domain_emails.list #=> an array of email addresses
213
+ @domain_emails.list.size #=> 5
214
+
215
+ # Enumerate each
216
+ @domain_emails.list.each do |email|
217
+ puts email
218
+ end
219
+
220
+ # DomainEmail properties
221
+ email = @domain_emails.list.first #=> admin@acmecerts.com
222
+ email.is_a?(String) #=> true
223
+ ```
224
+
225
+ ### Certificate Signing Request (CSR)
226
+ ```ruby
227
+ @csr = GlobeSSL::CertificateSigningRequest.new(
228
+ :country_name => "US",
229
+ :state_or_province_name => "South Sixly",
230
+ :locality_name => "Fivetown",
231
+ :organization_name => "Acme SSL Certs",
232
+ :organizational_unit_name => "acmecerts.com",
233
+ :common_name => "www.acmecerts.com",
234
+ :email_address => "support@acmecerts.com"
235
+ )
236
+
237
+ result = @csr.fetch #=> true
238
+
239
+ # If the fetch method fails it will return false and populate the errors collection attribute:
240
+ if result == false
241
+ @csr.errors.each do |err|
242
+ puts err
243
+ end
244
+ end
245
+
246
+ # CSR properties
247
+ @csr.private_key #=> -----BEGIN PRIVATE KEY-----\nMIIEv...
248
+ @csr.csr_code #=> -----BEGIN CERTIFICATE REQUEST-----\nMIIC/j...
249
+ @csr.fingerprint_sha1 #=> 42153B1CE...
250
+ @csr.fingerprint_md5 #=> AA24D856...
251
+
252
+ # Decoding the CSR
253
+ result = @csr.decode #=> true
254
+ @csr.decoded_csr #=> {"CN":"www.acmecerts.com","OU":"acmecerts.com"...
255
+ ```
256
+
257
+ ### Order SSL Certificate
258
+ ```ruby
259
+ @order = GlobeSSL::OrderSSLCertificate.new(
260
+ :admin_firstname => "Richard",
261
+ :admin_lastname => "Reseller",
262
+ :admin_email => "admin@acmecerts.com",
263
+ :admin_phone => "9995557856",
264
+ :admin_org => "Acme SSL Certs", # optional
265
+ :admin_jobtitle => "Administrator", # optional
266
+ :admin_address => "123 Fourth Street", # optional
267
+ :admin_city => "Fivetown", # optional
268
+ :admin_country => "US", # optional
269
+ :optional_admin_params => true,
270
+ :cert_signing_request => @csr, # CertificateSigningRequest object
271
+ :dcv_method => "email",
272
+ :period => 0,
273
+ :product => @product, # Product object
274
+ :webserver_type => 36, # nginx
275
+ :approver_email => "admin@acmecerts.com"
276
+ )
277
+
278
+ result = @order.purchase! #=> true
279
+
280
+ # If the purchase! method fails it will return false and populate the errors collection attribute:
281
+ if result == false
282
+ @order.errors.each do |err|
283
+ puts err
284
+ end
285
+ end
286
+
287
+ # Order properties
288
+ @order.order_id #=> 99999
289
+ @order.certificate_id #=> 303030
290
+ @order.amount #=> 0
291
+ @order.currency #=> USD
292
+ ```
293
+
294
+ ### SSL Certificate
295
+ ```ruby
296
+ @cert = GlobeSSL::SSLCertificate.new(
297
+ :id => @order.certificate_id # from above
298
+ )
299
+
300
+ result = @cert.fetch #=> true
301
+
302
+ # If the fetch method fails it will return false and populate the errors collection attribute:
303
+ if result == false
304
+ @cert.errors.each do |err|
305
+ puts err
306
+ end
307
+ end
308
+
309
+ # Certificate properties
310
+ @cert.order_id #=> 99999
311
+ @cert.partner_order_id #=> 865231756
312
+ @cert.status #=> Active
313
+ @cert.status_description #=> Active
314
+ @cert.dcv_method #=> email
315
+ @cert.dcv_email #=> admin@acmecerts.com
316
+ @cert.product #=> GlobeSSL::Product
317
+ @cert.domain #=> www.acmecerts.com
318
+ @cert.domains #=> array of domains if multi-domain product
319
+ @cert.total_domains #=> 1
320
+ @cert.period #=> 1 (year)
321
+ @cert.valid_from #=> 2015-10-06
322
+ @cert.valid_till #=> 2015-11-06
323
+ @cert.csr_code #=> -----BEGIN CERTIFICATE REQUEST-----\nMIIC/j...
324
+ @cert.crt_code #=> -----BEGIN CERTIFICATE-----\nMIIFdT...
325
+ @cert.ca_code #=> -----BEGIN CERTIFICATE-----\nMIIGBzCC...
326
+ ```
327
+
328
+ ### Domain Control Validation
329
+ ```ruby
330
+ @dcv = GlobeSSL::DomainControlValidation.new(
331
+ :certificate => cert, # from above
332
+ :dcv_method => 'email'
333
+ )
334
+
335
+ # Resend the domain control validation email:
336
+ result = @dcv.resend! #=> true
337
+
338
+ # Change the domain control validation method:
339
+ @dcv.method = 'http' # see GlobeSSL::DomainControlValidation::METHODS
340
+ @dcv.approver_email = "administrator@acmecerts.com"
341
+ result = @dcv.change! #=> true
342
+
343
+ # If the resend! or change! method fails it will return false and populate the errors collection attribute:
344
+ if result == false
345
+ @dcv.errors.each do |err|
346
+ puts err
347
+ end
348
+ end
349
+ ```
350
+
351
+ ### Country Codes
352
+ The **GlobeSSL Client** provides a constant hash of country codes. This list is derived from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2. The hash keys are ISO_3166-1_alpha-2 codes and the values are the country display name. The top 20 countries by number of Internet users are grouped first, see https://en.wikipedia.org/wiki/List_of_countries_by_number_of_Internet_users.
353
+
354
+ Example: access a country name by code:
355
+ ```ruby
356
+ GlobeSSL::COUNTRY_CODES['US'] #=> United States
357
+ ```
358
+ All the regular hash functions are available for find keys and values, but the hash is immutable. If you want to manipulate the list, for example to sort it differently; you will have to copy it into a new hash variable first.
359
+
360
+ ## Testing
361
+ GlobeSSL CA do not provide a test environment for their API. This is understandable since SSL Certificates are issued by Certificate Authorities. Everything about the API is about generating an SSL Certificate, so it stands to reason that a test environment would be quite difficult to create and support.
362
+
363
+ However, they do provide a way for resellers to use the API in a test capacity by allowing you to generate a `**FREE**` certificate. The certificate generated is a real working certificate, but it has a 3 month expiry date. The `product_id` for this certificate is `106`.
364
+
365
+ You will need to check if the product is returned by the `GlobeSSL::Products` class. If the product isn't in the list then contact GlobeSSL CA to request the product be enabled. I have been informed that the product is purely for test scenarios and abuse is monitored. Abusive behavior will result in the product being removed from your account.
366
+
367
+ ## To Do
368
+ - Document extended validation (`ev`) and organizational validation (`ov`) certificate type info supported in `GlobeSSL::OrderSSLCertificate`.
369
+ - Document `dns_names` and `approver_emails` for multi-domain certificate types supported in `GlobeSSL::OrderSSLCertificate`.
370
+ - Add `http` and `https` domain control validation method (`dcv_method`) documentation.
371
+ - Test suite with mocks for CI/CD scenarios.
372
+
373
+ ## Acknowledgements
374
+ #### Version 1.0.1
375
+ - Jurgen Jocubeit - President & CEO, [Brightcommerce, Inc.](http://brightcommerce.com)
376
+ - Zoltan Egresi - CTO, [GlobeSSL CA](https://globessl.com) (API guidance and live testing assistance)
377
+
378
+ ## License
379
+ This library is release in the public domain under the [MIT License](http://opensource.org/licenses/MIT).
380
+
381
+ ## Copyright
382
+ Copyright 2015 Brightcommerce, Inc.
383
+ All rights reserved.
@@ -0,0 +1,18 @@
1
+ require './lib/globessl/version'
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = 'globessl'
5
+ gem.version = GlobeSSL::VERSION::STRING
6
+ gem.authors = 'Jurgen Jocubeit'
7
+ gem.email = 'support@brightcommerce.com'
8
+ gem.homepage = 'https://github.com/brightcommerce/globessl'
9
+ gem.summary = GlobeSSL::VERSION::SUMMARY
10
+ gem.description = 'A Ruby API client for GlobeSSL CA resellers. This client provides almost all of the functionality exposed by v2 of their API.'
11
+ gem.license = 'MIT'
12
+ gem.metadata = { 'copyright' => 'Copyright 2015 Brightcommerce, Inc.' }
13
+ gem.files = `git ls-files`.split($/)
14
+ # gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ gem.require_path = 'lib'
16
+ gem.required_ruby_version = '>= 2.0.0'
17
+ gem.add_dependency 'virtus', '~> 1.0.3'
18
+ end
@@ -0,0 +1,45 @@
1
+ module GlobeSSL
2
+ autoload :AccountBalance, 'globessl/account_balance'
3
+ autoload :AccountDetails, 'globessl/account_details'
4
+ autoload :Base, 'globessl/base'
5
+ autoload :CertificateSigningRequest, 'globessl/certificate_signing_request'
6
+ autoload :Client, 'globessl/client'
7
+ autoload :Configuration, 'globessl/configuration'
8
+ autoload :DomainControlValidation, 'globessl/domain_control_validation'
9
+ autoload :DomainEmails, 'globessl/domain_emails'
10
+ autoload :OrderSSLCertificate, 'globessl/order_ssl_certificate'
11
+ autoload :Product, 'globessl/product'
12
+ autoload :Products, 'globessl/products'
13
+ autoload :SSLCertificate, 'globessl/ssl_certificate'
14
+ autoload :Version, 'globessl/version'
15
+ autoload :Webserver, 'globessl/webserver'
16
+ autoload :Webservers, 'globessl/webservers'
17
+
18
+ @@configuration = nil
19
+
20
+ def self.configure
21
+ @@configuration = Configuration.new
22
+ yield(configuration) if block_given?
23
+ configuration
24
+ end
25
+
26
+ def self.configuration
27
+ @@configuration || configure
28
+ end
29
+
30
+ def self.method_missing(method_sym, *arguments, &block)
31
+ if configuration.respond_to?(method_sym)
32
+ configuration.send(method_sym)
33
+ else
34
+ super
35
+ end
36
+ end
37
+
38
+ def self.respond_to?(method_sym, include_private = false)
39
+ if configuration.respond_to?(method_sym, include_private)
40
+ true
41
+ else
42
+ super
43
+ end
44
+ end
45
+ end