global_sign 1.0.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.md +25 -0
- data/README.md +100 -2
- data/global_sign.gemspec +3 -3
- data/lib/global_sign.rb +16 -0
- data/lib/global_sign/approver_info.rb +15 -0
- data/lib/global_sign/authorized_signer_info.rb +14 -0
- data/lib/global_sign/client.rb +16 -1
- data/lib/global_sign/csr_decoder.rb +2 -0
- data/lib/global_sign/csr_decoder/request.rb +29 -0
- data/lib/global_sign/csr_decoder/response.rb +36 -0
- data/lib/global_sign/dns_verification.rb +2 -0
- data/lib/global_sign/dns_verification/request.rb +55 -0
- data/lib/global_sign/dns_verification/response.rb +29 -0
- data/lib/global_sign/dns_verification_for_issue.rb +2 -0
- data/lib/global_sign/dns_verification_for_issue/request.rb +29 -0
- data/lib/global_sign/dns_verification_for_issue/response.rb +53 -0
- data/lib/global_sign/dv_approver_list.rb +2 -0
- data/lib/global_sign/dv_approver_list/request.rb +27 -0
- data/lib/global_sign/dv_approver_list/response.rb +33 -0
- data/lib/global_sign/dv_order.rb +2 -0
- data/lib/global_sign/dv_order/request.rb +72 -0
- data/lib/global_sign/dv_order/response.rb +19 -0
- data/lib/global_sign/ev_order.rb +2 -0
- data/lib/global_sign/ev_order/request.rb +132 -0
- data/lib/global_sign/ev_order/response.rb +19 -0
- data/lib/global_sign/jurisdiction_info.rb +12 -0
- data/lib/global_sign/order_getter_by_order_id/request.rb +11 -2
- data/lib/global_sign/order_getter_by_order_id/response.rb +52 -1
- data/lib/global_sign/organization_address.rb +17 -0
- data/lib/global_sign/organization_info.rb +26 -0
- data/lib/global_sign/organization_info/credit_agency.rb +8 -0
- data/lib/global_sign/organization_info_ev.rb +28 -0
- data/lib/global_sign/organization_info_ev/business_category_code.rb +9 -0
- data/lib/global_sign/ov_order.rb +2 -0
- data/lib/global_sign/ov_order/request.rb +79 -0
- data/lib/global_sign/ov_order/response.rb +19 -0
- data/lib/global_sign/requestor_info.rb +15 -0
- data/lib/global_sign/response.rb +11 -8
- data/lib/global_sign/url_verification/request.rb +3 -2
- data/lib/global_sign/url_verification/response.rb +4 -0
- data/lib/global_sign/url_verification_for_issue/response.rb +4 -0
- data/lib/global_sign/version.rb +1 -1
- metadata +45 -17
- data/CHANGELOG.md +0 -4
- data/wercker.yml +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: adff6a919745a77e1100fe13c7e40a5f2b39bd754fc12748b3146c4a6bb44dc9
|
4
|
+
data.tar.gz: ab6a1be53ba7da8d9f0f40004b908d3e25731a32d5b2dff5ac2f89fd91b511bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba107322e6fdc9b33b031dc3b1c1613e251ce95536901bf94454f8a476da5391e8c13457b7f5cdf945015ef957597d6882cba056085c4e593119ea09add1667a
|
7
|
+
data.tar.gz: 1109ff5ea85ee7af0986e24c522071df1397afd5697818454a91fa537af84ae06edc1d8d37c557b8ea0e91defc76e858dc19e95941320fe8bdb2f1ff9f3f1bd6
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
## 2.3.0
|
2
|
+
- Support GlobalSign API: EVOrder
|
3
|
+
|
4
|
+
## 2.2.0
|
5
|
+
|
6
|
+
- Added `options` optional keyword argument to `GlobalSign::Client`
|
7
|
+
- It supports `timeout` which specifies number of seconds to wait for request
|
8
|
+
|
9
|
+
## 2.1.1
|
10
|
+
- Fixed bug: `GlobalSign::OrderGetterByOrderId::Request` NoMethodError: undefined method `text` for nil:NilClass
|
11
|
+
|
12
|
+
## 2.1.0
|
13
|
+
|
14
|
+
- Support GlobalSign API: DecodeCSR
|
15
|
+
- Support GlobalSign API: DVDNSOrder & DVDNSVerificationForIssue
|
16
|
+
- Added `options` optional keyword argument to `GlobalSign::OrderGetterByOrderId::Request` for getting certificate info and fulfillment
|
17
|
+
|
18
|
+
## 2.0.0
|
19
|
+
|
20
|
+
- Added `product_code` required keyword argument to `GlobalSign::UrlVerification::Request` for selecting SSL certificate type
|
21
|
+
|
22
|
+
## 1.0.0
|
23
|
+
|
24
|
+
- Support GlobalSign API: URLVerification & URLVerificationForIssue
|
25
|
+
- Support GlobalSign API: GetOrderByOrderID
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# GlobalSign
|
2
2
|
|
3
|
-
[](https://badge.fury.io/rb/global_sign)
|
4
|
+

|
4
5
|
|
5
6
|
A Ruby interface to the [GlobalSign](https://www.globalsign.com/) API.
|
6
7
|
|
@@ -62,6 +63,7 @@ contract = GlobalSign::Contract.new(
|
|
62
63
|
)
|
63
64
|
|
64
65
|
request = GlobalSign::UrlVerification::Request.new(
|
66
|
+
product_code: 'DV_LOW_URL', # 'DV_HIGH_URL' or 'DV_LOW_URL'
|
65
67
|
order_kind: 'new', # If you request a new certificate
|
66
68
|
validity_period_months: 6,
|
67
69
|
csr: csr,
|
@@ -90,6 +92,7 @@ end
|
|
90
92
|
|
91
93
|
# Not need to give the argument 'contract_info'
|
92
94
|
request = GlobalSign::UrlVerification::Request.new(
|
95
|
+
product_code: 'DV_LOW_URL',
|
93
96
|
order_kind: 'new',
|
94
97
|
validity_period_months: 6,
|
95
98
|
csr: csr,
|
@@ -101,6 +104,7 @@ And you should give the argument `renewal_target_order_id` .
|
|
101
104
|
|
102
105
|
```ruby
|
103
106
|
request = GlobalSign::UrlVerification::Request.new(
|
107
|
+
product_code: 'DV_LOW_URL',
|
104
108
|
order_kind: 'renewal',
|
105
109
|
validity_period_months: 6,
|
106
110
|
csr: csr,
|
@@ -109,6 +113,31 @@ request = GlobalSign::UrlVerification::Request.new(
|
|
109
113
|
)
|
110
114
|
```
|
111
115
|
|
116
|
+
### DNS Verification
|
117
|
+
|
118
|
+
Verification flow is the same as URL Verification. Request class use the following:
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
client = GlobalSign::Client.new
|
122
|
+
|
123
|
+
request = GlobalSign::DnsVerification::Request.new(
|
124
|
+
product_code: 'DV_LOW_DNS',
|
125
|
+
order_kind: 'new',
|
126
|
+
validity_period_months: 6,
|
127
|
+
csr: csr,
|
128
|
+
contract_info: contract,
|
129
|
+
)
|
130
|
+
|
131
|
+
response = client.process(request)
|
132
|
+
|
133
|
+
if response.success?
|
134
|
+
puts "Successfully DNS Verification"
|
135
|
+
puts response.params # => { dns_txt: "xxxxx", verification_fqdn_list: ['example.com', 'www.example.com'], ... }
|
136
|
+
else
|
137
|
+
raise StandardError, "#{response.error_code}: #{response.error_message}"
|
138
|
+
end
|
139
|
+
```
|
140
|
+
|
112
141
|
### URL Verification for Issue
|
113
142
|
|
114
143
|
```ruby
|
@@ -135,10 +164,36 @@ else
|
|
135
164
|
end
|
136
165
|
```
|
137
166
|
|
167
|
+
### DNS Verification for Issue
|
168
|
+
|
169
|
+
```ruby
|
170
|
+
client = GlobalSign::Client.new
|
171
|
+
|
172
|
+
# You can use ApproverFQDN value such as:
|
173
|
+
# - www.example.com
|
174
|
+
# - example.com
|
175
|
+
|
176
|
+
request = GlobalSign::UrlVerificationForIssue::Request.new(
|
177
|
+
order_id: 'xxxx123456789',
|
178
|
+
approver_fqdn: 'www.example.com',
|
179
|
+
)
|
180
|
+
|
181
|
+
response = client.process(request)
|
182
|
+
|
183
|
+
if response.success?
|
184
|
+
puts "Successfully DNS Verification for Issue"
|
185
|
+
puts response.params # => { fulfillment: { ca_certificates: [{ ca_cert: "xxxxx" }, ...]}, ... }
|
186
|
+
else
|
187
|
+
raise StandardError, "#{response.error_code}: #{response.error_message}"
|
188
|
+
end
|
189
|
+
```
|
190
|
+
|
138
191
|
### Get Order by OrderID
|
139
192
|
|
140
193
|
```ruby
|
141
|
-
request = GlobalSign::OrderGetterByOrderId::Request.new(
|
194
|
+
request = GlobalSign::OrderGetterByOrderId::Request.new(
|
195
|
+
order_id: 'xxxx123456789'
|
196
|
+
)
|
142
197
|
response = client.process(request)
|
143
198
|
|
144
199
|
puts response.params # => { order_id: "xxxx123456789", order_status: "2", ... }
|
@@ -147,6 +202,49 @@ puts response.params # => { order_id: "xxxx123456789", order_status: "2", ... }
|
|
147
202
|
puts response.order_status_text # => "phishing_checking"
|
148
203
|
```
|
149
204
|
|
205
|
+
You can specify request options.
|
206
|
+
|
207
|
+
```ruby
|
208
|
+
# certificate_info option
|
209
|
+
request = GlobalSign::OrderGetterByOrderId::Request.new(
|
210
|
+
order_id: 'xxxx123456789',
|
211
|
+
options: { certificate_info: true }
|
212
|
+
)
|
213
|
+
response = client.process(request)
|
214
|
+
|
215
|
+
puts response.params[:certificate_info] # => { certificate_status: '4', start_date: '2016-10-06T14:53:23.000+09:00', ... }
|
216
|
+
|
217
|
+
# fulfillment option
|
218
|
+
request = GlobalSign::OrderGetterByOrderId::Request.new(
|
219
|
+
order_id: 'xxxx123456789',
|
220
|
+
options: { fulfillment: true }
|
221
|
+
)
|
222
|
+
response = client.process(request)
|
223
|
+
|
224
|
+
puts response.params[:fulfillment] # => { ca_certificates: [{ ca_cert: "xxxxx" }, ...]}
|
225
|
+
```
|
226
|
+
|
227
|
+
### Decode CSR
|
228
|
+
|
229
|
+
```ruby
|
230
|
+
request = GlobalSign::CsrDecoder::Request.new(
|
231
|
+
product_type: 'DV_LOW',
|
232
|
+
csr: csr
|
233
|
+
)
|
234
|
+
response = client.process(request)
|
235
|
+
|
236
|
+
puts response.params # => { common_name: "www.example.com", ... }
|
237
|
+
```
|
238
|
+
|
239
|
+
### Client options
|
240
|
+
|
241
|
+
`GlobalSign::Client` allows `options` argument in order to specify its behavior.
|
242
|
+
For now, it supports `timeout` which specifies number of seconds to wait for request.
|
243
|
+
|
244
|
+
```ruby
|
245
|
+
client = GlobalSign::Client.new(options: { timeout: 120 })
|
246
|
+
```
|
247
|
+
|
150
248
|
## Contributing
|
151
249
|
|
152
250
|
1. Create your feature branch (git checkout -b my-new-feature)
|
data/global_sign.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
-
f.match(%r{^(test|spec|features)/})
|
18
|
+
f.match(%r{^(.github|test|spec|features)/})
|
19
19
|
end
|
20
20
|
spec.bindir = 'exe'
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
@@ -26,8 +26,8 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_runtime_dependency 'faraday'
|
27
27
|
spec.add_runtime_dependency 'nokogiri'
|
28
28
|
|
29
|
-
spec.add_development_dependency 'bundler'
|
30
|
-
spec.add_development_dependency 'rake'
|
29
|
+
spec.add_development_dependency 'bundler'
|
30
|
+
spec.add_development_dependency 'rake'
|
31
31
|
spec.add_development_dependency 'rspec'
|
32
32
|
spec.add_development_dependency 'webmock'
|
33
33
|
spec.add_development_dependency 'vcr'
|
data/lib/global_sign.rb
CHANGED
@@ -3,6 +3,15 @@ require 'active_support/core_ext/hash/conversions'
|
|
3
3
|
require 'global_sign/version'
|
4
4
|
require 'global_sign/client'
|
5
5
|
require 'global_sign/contract'
|
6
|
+
require 'global_sign/organization_address'
|
7
|
+
require 'global_sign/organization_info'
|
8
|
+
require 'global_sign/organization_info/credit_agency'
|
9
|
+
require 'global_sign/organization_info_ev'
|
10
|
+
require 'global_sign/organization_info_ev/business_category_code'
|
11
|
+
require 'global_sign/requestor_info'
|
12
|
+
require 'global_sign/approver_info'
|
13
|
+
require 'global_sign/authorized_signer_info'
|
14
|
+
require 'global_sign/jurisdiction_info'
|
6
15
|
require 'global_sign/request_xml_builder'
|
7
16
|
require 'global_sign/request'
|
8
17
|
require 'global_sign/response'
|
@@ -11,6 +20,13 @@ require 'global_sign/order_status'
|
|
11
20
|
require 'global_sign/url_verification'
|
12
21
|
require 'global_sign/url_verification_for_issue'
|
13
22
|
require 'global_sign/order_getter_by_order_id'
|
23
|
+
require 'global_sign/csr_decoder'
|
24
|
+
require 'global_sign/dns_verification'
|
25
|
+
require 'global_sign/dns_verification_for_issue'
|
26
|
+
require 'global_sign/dv_approver_list'
|
27
|
+
require 'global_sign/dv_order'
|
28
|
+
require 'global_sign/ov_order'
|
29
|
+
require 'global_sign/ev_order'
|
14
30
|
|
15
31
|
module GlobalSign
|
16
32
|
class << self
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module GlobalSign
|
2
|
+
class ApproverInfo
|
3
|
+
attr_accessor :first_name, :last_name, :function, :organization_name, :organization_unit, :phone_number, :email
|
4
|
+
|
5
|
+
def initialize(first_name:, last_name:, function: nil, organization_name:, organization_unit: nil, phone_number:, email:)
|
6
|
+
@first_name = first_name
|
7
|
+
@last_name = last_name
|
8
|
+
@function = function
|
9
|
+
@organization_name = organization_name
|
10
|
+
@organization_unit = organization_unit
|
11
|
+
@phone_number = phone_number
|
12
|
+
@email = email
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module GlobalSign
|
2
|
+
class AuthorizedSignerInfo
|
3
|
+
attr_accessor :first_name, :last_name, :function, :organization_name, :phone_number, :email
|
4
|
+
|
5
|
+
def initialize(first_name:, last_name:, function: nil, organization_name:, phone_number:, email:)
|
6
|
+
@first_name = first_name
|
7
|
+
@last_name = last_name
|
8
|
+
@function = function
|
9
|
+
@organization_name = organization_name
|
10
|
+
@phone_number = phone_number
|
11
|
+
@email = email
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/global_sign/client.rb
CHANGED
@@ -2,12 +2,13 @@ require 'faraday'
|
|
2
2
|
|
3
3
|
module GlobalSign
|
4
4
|
class Client
|
5
|
-
def initialize
|
5
|
+
def initialize(options: {})
|
6
6
|
@configuration = GlobalSign.configuration
|
7
7
|
|
8
8
|
@connection = Faraday::Connection.new(url: @configuration.endpoint) do |conn|
|
9
9
|
conn.request :url_encoded
|
10
10
|
conn.adapter Faraday.default_adapter
|
11
|
+
conn.options[:timeout] = options[:timeout] if options[:timeout].present?
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
@@ -25,12 +26,26 @@ module GlobalSign
|
|
25
26
|
|
26
27
|
def find_response_class_for(request)
|
27
28
|
case request
|
29
|
+
when GlobalSign::CsrDecoder::Request
|
30
|
+
GlobalSign::CsrDecoder::Response
|
31
|
+
when GlobalSign::DnsVerification::Request
|
32
|
+
GlobalSign::DnsVerification::Response
|
33
|
+
when GlobalSign::DnsVerificationForIssue::Request
|
34
|
+
GlobalSign::DnsVerificationForIssue::Response
|
28
35
|
when GlobalSign::UrlVerification::Request
|
29
36
|
GlobalSign::UrlVerification::Response
|
30
37
|
when GlobalSign::UrlVerificationForIssue::Request
|
31
38
|
GlobalSign::UrlVerificationForIssue::Response
|
32
39
|
when GlobalSign::OrderGetterByOrderId::Request
|
33
40
|
GlobalSign::OrderGetterByOrderId::Response
|
41
|
+
when GlobalSign::DVApproverList::Request
|
42
|
+
GlobalSign::DVApproverList::Response
|
43
|
+
when GlobalSign::DVOrder::Request
|
44
|
+
GlobalSign::DVOrder::Response
|
45
|
+
when GlobalSign::OVOrder::Request
|
46
|
+
GlobalSign::OVOrder::Response
|
47
|
+
when GlobalSign::EVOrder::Request
|
48
|
+
GlobalSign::EVOrder::Response
|
34
49
|
else
|
35
50
|
raise ArgumentError, 'invalid request argument'
|
36
51
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module GlobalSign
|
2
|
+
module CsrDecoder
|
3
|
+
class Request < GlobalSign::Request
|
4
|
+
def initialize(csr:, product_type:)
|
5
|
+
@csr = csr
|
6
|
+
@product_type = product_type
|
7
|
+
end
|
8
|
+
|
9
|
+
def path
|
10
|
+
'GASService'
|
11
|
+
end
|
12
|
+
|
13
|
+
def action
|
14
|
+
'DecodeCSR'
|
15
|
+
end
|
16
|
+
|
17
|
+
def request_header
|
18
|
+
:QueryRequestHeader
|
19
|
+
end
|
20
|
+
|
21
|
+
def params
|
22
|
+
{
|
23
|
+
CSR: @csr,
|
24
|
+
ProductType: @product_type
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module GlobalSign
|
2
|
+
module CsrDecoder
|
3
|
+
class Response < GlobalSign::Response
|
4
|
+
module XPath
|
5
|
+
CSRData = '//Response/CSRData'
|
6
|
+
CertificatePreview = '//Response/CertificatePreview'
|
7
|
+
end
|
8
|
+
|
9
|
+
def response_header
|
10
|
+
:QueryResponseHeader
|
11
|
+
end
|
12
|
+
|
13
|
+
def params
|
14
|
+
@params ||= {
|
15
|
+
csr_data: detail(@xml.xpath(XPath::CSRData)),
|
16
|
+
certificate_preview: detail(@xml.xpath(XPath::CertificatePreview))
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def detail(data)
|
23
|
+
{
|
24
|
+
common_name: data.at('CommonName').try(:text) || '',
|
25
|
+
organization: data.at('Organization').try(:text) || '',
|
26
|
+
organization_unit: data.at('Organization').try(:text) || '',
|
27
|
+
locality: data.at('Locality').try(:text) || '',
|
28
|
+
state: data.at('State').try(:text) || '',
|
29
|
+
country: data.at('Country').try(:text) || '',
|
30
|
+
email_address: data.at('EmailAddress').try(:text) || '',
|
31
|
+
key_length: data.at('KeyLength').try(:text) || ''
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module GlobalSign
|
2
|
+
module DnsVerification
|
3
|
+
class Request < GlobalSign::UrlVerification::Request
|
4
|
+
def initialize(product_code:, order_kind:, validity_period_months:, csr:, renewal_target_order_id: nil, contract_info: nil)
|
5
|
+
@product_code = product_code
|
6
|
+
@order_kind = order_kind
|
7
|
+
@validity_period_months = validity_period_months
|
8
|
+
@csr = csr
|
9
|
+
@renewal_target_order_id = renewal_target_order_id
|
10
|
+
@contract_info = contract_info || GlobalSign.contract
|
11
|
+
end
|
12
|
+
|
13
|
+
def path
|
14
|
+
'ServerSSLService'
|
15
|
+
end
|
16
|
+
|
17
|
+
def action
|
18
|
+
'DVDNSOrder'
|
19
|
+
end
|
20
|
+
|
21
|
+
def request_header
|
22
|
+
:OrderRequestHeader
|
23
|
+
end
|
24
|
+
|
25
|
+
def params
|
26
|
+
_params = {
|
27
|
+
OrderRequestParameter: {
|
28
|
+
ProductCode: @product_code,
|
29
|
+
OrderKind: @order_kind,
|
30
|
+
Licenses: 1,
|
31
|
+
ValidityPeriod: {
|
32
|
+
Months: @validity_period_months
|
33
|
+
},
|
34
|
+
CSR: @csr,
|
35
|
+
},
|
36
|
+
ContactInfo: {
|
37
|
+
FirstName: @contract_info.first_name,
|
38
|
+
LastName: @contract_info.last_name,
|
39
|
+
Phone: @contract_info.phone_number,
|
40
|
+
Email: @contract_info.email
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
# require `RenewalTargetOrderID` to request a renewal certificate
|
45
|
+
if @order_kind == 'renewal'
|
46
|
+
_params[:OrderRequestParameter].merge!(
|
47
|
+
{ RenewalTargetOrderID: @renewal_target_order_id }
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
_params
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|