varanus 0.3.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 230026bcb2def2b083ca884cd2302daf51407b6d57aa212c66d208d29a335b11
4
- data.tar.gz: 69728f0eb64f2735e32bfa4b1d77e8bd4fde87b47f3f6e029a7ccbe441d85f3f
3
+ metadata.gz: 0b74f92a4981ac8294eb1fe84c4361f1dc3a175be3735f7d485f7b5edd9963aa
4
+ data.tar.gz: 5a38ba280217b30fe842a99786acf761f081d135f1180cb3950bfbab5f50904a
5
5
  SHA512:
6
- metadata.gz: 6708842c8291bedf4b3d71d29b7437aba40ea1d1148e090f023eff5ba130abe8e74f278c95a67d39ca8346e37574a576f693e9caee946b02a68f58e4811ac636
7
- data.tar.gz: 6db3621c1415feafb91eb3eb46407a240942f142d5b5aea3024bd44c644bf2232d73155c5908da51f7e85f6affc23533626e281d12848c8cd9293b4265517695
6
+ metadata.gz: 02ece0e219a9f47fe84ec8faaf406194f13082a1797793c23760643b8547140307fc243550e7d36d1d8412ca586850d0535a419a2dc50a9b7b90a4e4f660af67
7
+ data.tar.gz: 80435d29c565a99a191a85938ae4a505b01c68a38c608d063e9c10809d4eae1c2a8cad9872a9cc3f5b518a9e1084e7c625a40f287e66e1c17900ae659200095c
data/.travis.yml CHANGED
@@ -6,10 +6,9 @@ sudo: false
6
6
  language: ruby
7
7
  cache: bundler
8
8
  rvm:
9
- - 2.3
10
- - 2.4
11
9
  - 2.5
12
10
  - 2.6
11
+ - 2.7
13
12
  before_install: gem install bundler -v 1.16.5
14
13
  before_script:
15
14
  - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ### Version 0.6.0 (2020-02-01)
2
+ * Add Varanus::SSL#report
3
+ * Varanus::Reports (Varanus#reports) is now deprecated.
4
+
5
+ ### Version 0.5.1 (2021-01-28)
6
+ * Varanus::SSL::CSR - support EC certs
7
+
8
+ ### Version 0.5.0 (2021-01-26)
9
+ * Add Varanus::Domain
10
+ * Add Varanus::SSL#list and Varanus::SSL#info
11
+ * Add Varanus::Organization
12
+
13
+ ### 0.4.0 (2021-01-06)
14
+ * Add Varanus::DCV
15
+
16
+ ### 0.3.1 (2020-10-14)
17
+ * Fix issue when Sectigo reports two identical 'Short Life' certs
18
+
1
19
  ### 0.3.0 (2020-08-24)
2
20
  * Add support for new 'Short Life' certs
3
21
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- varanus (0.3.0)
4
+ varanus (0.6.0)
5
5
  faraday
6
6
  faraday_middleware
7
7
  savon (~> 2.0)
@@ -9,61 +9,61 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- addressable (2.5.2)
13
- public_suffix (>= 2.0.2, < 4.0)
12
+ addressable (2.7.0)
13
+ public_suffix (>= 2.0.2, < 5.0)
14
14
  akami (1.3.1)
15
15
  gyoku (>= 0.4.0)
16
16
  nokogiri
17
17
  ast (2.4.1)
18
- builder (3.2.3)
19
- crack (0.4.3)
20
- safe_yaml (~> 1.0.0)
21
- docile (1.3.1)
22
- faraday (0.15.3)
18
+ builder (3.2.4)
19
+ crack (0.4.5)
20
+ rexml
21
+ docile (1.3.4)
22
+ faraday (1.3.0)
23
+ faraday-net_http (~> 1.0)
23
24
  multipart-post (>= 1.2, < 3)
24
- faraday_middleware (0.12.2)
25
- faraday (>= 0.7.4, < 1.0)
25
+ ruby2_keywords
26
+ faraday-net_http (1.0.0)
27
+ faraday_middleware (1.0.0)
28
+ faraday (~> 1.0)
26
29
  gyoku (1.3.1)
27
30
  builder (>= 2.1.2)
28
- hashdiff (0.3.7)
29
- httpi (2.4.4)
31
+ hashdiff (1.0.1)
32
+ httpi (2.4.5)
30
33
  rack
31
34
  socksify
32
- json (2.1.0)
33
- metaclass (0.0.4)
34
- mini_portile2 (2.3.0)
35
- minitest (5.11.3)
35
+ minitest (5.14.3)
36
36
  minitest-rg (5.2.0)
37
37
  minitest (~> 5.0)
38
- mocha (1.7.0)
39
- metaclass (~> 0.0.1)
40
- multipart-post (2.0.0)
41
- nokogiri (1.8.5)
42
- mini_portile2 (~> 2.3.0)
38
+ mocha (1.12.0)
39
+ multipart-post (2.1.1)
40
+ nokogiri (1.11.1-x86_64-linux)
41
+ racc (~> 1.4)
43
42
  nori (2.6.0)
44
- parallel (1.19.2)
45
- parser (2.7.1.4)
43
+ parallel (1.20.1)
44
+ parser (3.0.0.0)
46
45
  ast (~> 2.4.1)
47
- public_suffix (3.0.3)
48
- rack (2.0.6)
46
+ public_suffix (4.0.6)
47
+ racc (1.5.2)
48
+ rack (2.2.3)
49
49
  rainbow (3.0.0)
50
50
  rake (10.5.0)
51
- regexp_parser (1.7.1)
51
+ regexp_parser (2.0.3)
52
52
  rexml (3.2.4)
53
- rubocop (0.89.1)
53
+ rubocop (1.7.0)
54
54
  parallel (~> 1.10)
55
- parser (>= 2.7.1.1)
55
+ parser (>= 2.7.1.5)
56
56
  rainbow (>= 2.2.2, < 4.0)
57
- regexp_parser (>= 1.7)
57
+ regexp_parser (>= 1.8, < 3.0)
58
58
  rexml
59
- rubocop-ast (>= 0.3.0, < 1.0)
59
+ rubocop-ast (>= 1.2.0, < 2.0)
60
60
  ruby-progressbar (~> 1.7)
61
61
  unicode-display_width (>= 1.4.0, < 2.0)
62
- rubocop-ast (0.3.0)
63
- parser (>= 2.7.1.4)
64
- ruby-progressbar (1.10.1)
65
- safe_yaml (1.0.4)
66
- savon (2.12.0)
62
+ rubocop-ast (1.4.0)
63
+ parser (>= 2.7.1.5)
64
+ ruby-progressbar (1.11.0)
65
+ ruby2_keywords (0.0.2)
66
+ savon (2.12.1)
67
67
  akami (~> 1.2)
68
68
  builder (>= 2.1.2)
69
69
  gyoku (~> 1.2)
@@ -71,21 +71,23 @@ GEM
71
71
  nokogiri (>= 1.8.1)
72
72
  nori (~> 2.4)
73
73
  wasabi (~> 3.4)
74
- simplecov (0.16.1)
74
+ simplecov (0.21.1)
75
75
  docile (~> 1.1)
76
- json (>= 1.8, < 3)
77
- simplecov-html (~> 0.10.0)
78
- simplecov-html (0.10.2)
76
+ simplecov-html (~> 0.11)
77
+ simplecov_json_formatter (~> 0.1)
78
+ simplecov-html (0.12.3)
79
+ simplecov_json_formatter (0.1.2)
79
80
  socksify (1.7.1)
80
81
  unicode-display_width (1.7.0)
81
- wasabi (3.5.0)
82
+ wasabi (3.6.1)
83
+ addressable
82
84
  httpi (~> 2.0)
83
85
  nokogiri (>= 1.4.2)
84
- webmock (3.4.2)
86
+ webmock (3.11.0)
85
87
  addressable (>= 2.3.6)
86
88
  crack (>= 0.3.2)
87
- hashdiff
88
- yard (0.9.16)
89
+ hashdiff (>= 0.4.0, < 2.0.0)
90
+ yard (0.9.26)
89
91
 
90
92
  PLATFORMS
91
93
  ruby
data/lib/varanus.rb CHANGED
@@ -14,8 +14,40 @@ class Varanus
14
14
  @password = password
15
15
  end
16
16
 
17
- # Retrieve Reports instance
18
- # @return [Varanus::Reports]
17
+ # :nodoc:
18
+ def connection
19
+ @connection ||= Faraday.new(url: 'https://cert-manager.com/api',
20
+ request: { timeout: 300 }) do |conn|
21
+ conn.request :json
22
+ conn.response :json, content_type: /\bjson$/
23
+
24
+ conn.headers['login'] = @username
25
+ conn.headers['password'] = @password
26
+ conn.headers['customerUri'] = @customer_uri
27
+
28
+ conn.adapter Faraday.default_adapter
29
+ end
30
+ end
31
+
32
+ # Retrive DCV instance
33
+ # @return [Varanus::DCV]
34
+ def dcv
35
+ @dcv ||= DCV.new(self)
36
+ end
37
+
38
+ # Retrieve Domain instance
39
+ # @return [Varanus::Domain]
40
+ def domain
41
+ @domain ||= Domain.new(self)
42
+ end
43
+
44
+ # Retrieve Organization instance
45
+ # @return [Varanus::Organization]
46
+ def organization
47
+ @organization ||= Organization.new(self)
48
+ end
49
+
50
+ # DEPRECATED
19
51
  def reports
20
52
  @reports ||= Reports.new(self)
21
53
  end
@@ -35,6 +67,10 @@ require 'savon'
35
67
 
36
68
  # Require other files in this gem
37
69
  require 'varanus/error'
70
+ require 'varanus/rest_resource'
71
+ require 'varanus/dcv'
72
+ require 'varanus/domain'
73
+ require 'varanus/organization'
38
74
  require 'varanus/reports'
39
75
  require 'varanus/ssl'
40
76
  require 'varanus/ssl/csr'
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ # An connection to the DCV API. This should not be initialized directly. Instead,
4
+ # use Varanus#dcv
5
+ class Varanus::DCV < Varanus::RestResource
6
+ # Returns an Array of DCV information about searched for domains.
7
+ # This method will automatically page through all results
8
+ # @param opts [Hash] - all opts are optional
9
+ # @option opts [String] :domain Domain to search for
10
+ # @option opts [Integer] :org ID of organization
11
+ # @option opts [Integer] :department ID of department
12
+ # @option opts [String] :dcvStatus
13
+ # @option opts [String] :orderStatus
14
+ # @option opts [Integer] :expiresIn Expires in (days)
15
+ #
16
+ # Results will included an extra 'expiration_date_obj' if 'expirationDate' is in the
17
+ # response
18
+ def search opts = {}
19
+ get_with_size_and_position('dcv/v2/validation', opts).map(&method(:_format_status))
20
+ end
21
+
22
+ # Start domain validation process. This must be called before #submit is called
23
+ # @option domain [String] domain to validate
24
+ # @option type [String] Type of validation. Must be one of 'http', 'https', 'cname',
25
+ # or 'email'
26
+ def start domain, type
27
+ post("dcv/v1/validation/start/domain/#{type}", domain: domain)
28
+ end
29
+
30
+ # Retrieve DCV status for a single domain
31
+ # Result will included an extra 'expiration_date_obj' if 'expirationDate' is in the
32
+ # response
33
+ def status domain
34
+ _format_status(post('dcv/v2/validation/status', domain: domain))
35
+ end
36
+
37
+ # Submit domain validation for verficiation. This must be called after #start
38
+ # @option domain [String] domain to validate
39
+ # @option type [String] Type of validation. Must be one of 'http', 'https', 'cname',
40
+ # or 'email'
41
+ # @option email_address [String] This is required of +type+ is 'email'. Otherwise, it is
42
+ # ignored.
43
+ def submit domain, type, email_address = nil
44
+ if type.to_s == 'email'
45
+ raise ArgumentError, 'email_address must be specified' if email_address.nil?
46
+
47
+ post('dcv/v1/validation/submit/domain/email', domain: domain,
48
+ email: email_address)
49
+ else
50
+ post("dcv/v1/validation/submit/domain/#{type}", domain: domain)
51
+ end
52
+ end
53
+
54
+ private
55
+
56
+ def _format_status status
57
+ return status unless status['expirationDate']
58
+
59
+ status.merge('expiration_date_obj' =>
60
+ Date.strptime(status['expirationDate'], '%Y-%m-%d'))
61
+ end
62
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A connection to the Domain API
4
+ class Varanus::Domain < Varanus::RestResource
5
+ # Create a new domain. The domain may need to be manually approved after this is
6
+ # called.
7
+ # +name+ is the domain
8
+ # +delegations+ is an Array of Hashes. Each Hash should have an 'orgId' and
9
+ # 'certTypes' key
10
+ # opts may include the following keys:
11
+ # - :description - optional - String
12
+ # - :active - optional - Boolean (defaults to +true+)
13
+ # - :allow_subdomains - optional - set to +false+ if you don't want to allow sub
14
+ # domains for this entry
15
+ #
16
+ # @returns [String] - URL for newly created domain
17
+ def create domain, delegations, opts = {}
18
+ opts = opts.dup
19
+ allow_subdomains = opts.delete(:allow_subdomains)
20
+ domain = "*.#{domain}" if allow_subdomains != false && !domain.start_with?('*.')
21
+
22
+ result = @varanus.connection.post('domain/v1',
23
+ opts.merge(name: domain, delegations: delegations))
24
+ check_result result
25
+ result.headers['Location']
26
+ end
27
+
28
+ # Return info on domain. +id+ must be the id returned by #list
29
+ def info id
30
+ get("domain/v1/#{id}")
31
+ end
32
+
33
+ def list opts = {}
34
+ get_with_size_and_position('domain/v1', opts)
35
+ end
36
+
37
+ def list_with_info opts = {}
38
+ domains = list(opts)
39
+ domains.map! { |domain| info(domain['id']) }
40
+ domains
41
+ end
42
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A connection to the Organization API
4
+ class Varanus::Organization < Varanus::RestResource
5
+ # Return info on organization.
6
+ def info id
7
+ get("organization/v1/#{id}")
8
+ end
9
+
10
+ def list
11
+ get('organization/v1')
12
+ end
13
+ end
@@ -18,20 +18,19 @@ class Varanus::Reports
18
18
  @varanus = varanus
19
19
  end
20
20
 
21
+ # DEPRECATED: Please use Varanus::Domain#list_with_info instead.
21
22
  def domains
23
+ warn 'DEPRECATION WARNING: Varanus::Reports#domains is deprecated. ' \
24
+ 'Use Varanus::Domain#list_with_info instead'
22
25
  r = soap_call :get_domain_report, {}
23
26
  format_results r[:report_row_domains]
24
27
  end
25
28
 
26
- # Return report on SSL request
27
- # @param [opts] [Hash]
28
- # @option opts [String, Array] :orgs Name(s) of organizations (departments) to limit
29
- # the report to. If this is unset, results from all departments are returned.
30
- # @option opts [Symbol] :status (:any) One of :any, :requested, :downloaded, :revoked,
31
- # :expired, :pending_download, :not_enrolled. :downloaded and :pending_download
32
- # mean the cert has been enrolled/signed.
33
- # @return [Array<Hash>]
29
+ # DEPRECATED: Please use Varanus::SSL#report instead.
34
30
  def ssl opts = {}
31
+ warn 'DEPRECATION WARNING: Varanus::Reports#ssl is deprecated. ' \
32
+ 'Use Varanus::SSL#report instead'
33
+
35
34
  msg = { organizationNames: nil, certificateStatus: 0 }
36
35
 
37
36
  msg[:organizationNames] = Array(opts[:orgs]).join(',') if opts.include? :orgs
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ # An abstract class for rest resources
4
+ # Rest resources should not be initialized directly. They should be created by methods
5
+ # on Varanus
6
+ class Varanus::RestResource
7
+ # :nodoc:
8
+ def initialize varanus
9
+ @varanus = varanus
10
+ end
11
+
12
+ private
13
+
14
+ def check_result result
15
+ body = result.body
16
+ return unless body.is_a?(Hash)
17
+ return if body['code'].nil?
18
+
19
+ klass = Varanus::Error
20
+ if body['code'] == 0 && body['description'] =~ /process/
21
+ klass = Varanus::Error::StillProcessing
22
+ end
23
+
24
+ raise klass.new(body['code'], body['description'])
25
+ end
26
+
27
+ def get path, *args
28
+ result = @varanus.connection.get(path, *args)
29
+ check_result result
30
+ result.body
31
+ end
32
+
33
+ # Performs multiple GETs with varying positions to ensure all results are returned.
34
+ def get_with_size_and_position path, opts = {}
35
+ size = opts[:size] || 200
36
+ position = opts[:position] || 0
37
+
38
+ results = []
39
+ loop do
40
+ params = { size: size, position: position }.merge(opts)
41
+ new_results = get(path, params)
42
+ results += new_results
43
+ break if new_results.length < size
44
+
45
+ position += size
46
+ end
47
+
48
+ results
49
+ end
50
+
51
+ def post path, *args
52
+ result = @varanus.connection.post(path, *args)
53
+ check_result result
54
+ result.body
55
+ end
56
+ end
data/lib/varanus/ssl.rb CHANGED
@@ -2,11 +2,23 @@
2
2
 
3
3
  # An connection to the SSL/TSL API. This should not be initialized directly. Instead,
4
4
  # use Varanus#ssl
5
- class Varanus::SSL
6
- # @note Do not call this directly. Use {Varanus#ssl} to initialize
7
- def initialize varanus
8
- @varanus = varanus
9
- end
5
+ class Varanus::SSL < Varanus::RestResource
6
+ # rubocop:disable Style/MutableConstant
7
+ # These constants are frozen, rubocop is failing to detect the freeze.
8
+ # See https://github.com/rubocop-hq/rubocop/issues/4406
9
+ REPORT_CERT_STATUS = { any: 0, requested: 1, issued: 2, revoked: 3, expired: 4 }
10
+ REPORT_CERT_STATUS.default_proc = proc { |_h, k|
11
+ raise ArgumentError, "Unknown certificateStatus: #{k.inspect}"
12
+ }
13
+ REPORT_CERT_STATUS.freeze
14
+
15
+ REPORT_CERT_DATE_ATTR = { revocation_date: 2, expiration_date: 3, request_date: 4,
16
+ issue_date: 5 }
17
+ REPORT_CERT_DATE_ATTR.default_proc = proc { |_h, k|
18
+ raise ArgumentError, "Unknown certificateDateAttribute: #{k.inspect}"
19
+ }
20
+ REPORT_CERT_DATE_ATTR.freeze
21
+ # rubocop:enable Style/MutableConstant
10
22
 
11
23
  # Returns the option from #certificate_types that best matches the csr.
12
24
  # @param csr [Varanus::SSL::CSR]
@@ -16,7 +28,8 @@ class Varanus::SSL
16
28
  return types.first if types.length <= 1
17
29
 
18
30
  regexp = cert_type_regexp(csr)
19
- return types.find { |ct| ct['name'] =~ regexp } if regexp
31
+ typ = types.find { |ct| ct['name'] =~ regexp } if regexp
32
+ return typ unless typ.nil?
20
33
 
21
34
  types.find do |ct|
22
35
  ct['name'] =~ /\bSSL\b/ && ct['name'] !~ /(?:Multi.?Domain|Wildcard)/i
@@ -26,7 +39,7 @@ class Varanus::SSL
26
39
  # Certificate types that can be used to sign a cert
27
40
  # @return [Array<Hash>]
28
41
  def certificate_types
29
- @certificate_types ||= get('types')
42
+ @certificate_types ||= get('ssl/v1/types')
30
43
  end
31
44
 
32
45
  # Return Array of certificate types based on standard sorting.
@@ -56,7 +69,37 @@ class Varanus::SSL
56
69
  # @raise [Varanus::Error::StillProcessing] Cert is still being signed
57
70
  # @return [String] Certificate
58
71
  def collect id, type = 'x509'
59
- get("collect/#{id}/#{type}")
72
+ get("ssl/v1/collect/#{id}/#{type}")
73
+ end
74
+
75
+ # Returns info on the SSL certificate of the given name
76
+ def info id
77
+ get("ssl/v1/#{id}")
78
+ end
79
+
80
+ # List certs ids and serial numbers
81
+ def list opts = {}
82
+ get_with_size_and_position('ssl/v1', opts)
83
+ end
84
+
85
+ # Return a report (list) of SSL certs based on the options.
86
+ # The report includes a full set of details about the certs, not just the id/cn/serial
87
+ # +opts+ can include:
88
+ # (all are optional)
89
+ # - :organizationIds - Array - ids of organization/departments to include certs for
90
+ # - :certificateStatus - :any, :requested, :issued, :revoked, or :expired
91
+ # - :certificateDateAttribute - Specifies what fields :from and/or :to refer to.
92
+ # Can be: :revocation_date, :expiration_date,
93
+ # :request_date, or :issue_date
94
+ # - :from - Date - based on :certificateDateAttribute
95
+ # - :to - Date - based on :certificateDateAttribute
96
+ def report opts = { certificateStatus: :any }
97
+ # Default is to request any certificate status since the API call will fail if no
98
+ # options are passed
99
+ opts = { certificateStatus: :any } if opts.empty?
100
+ opts = _parse_report_opts(opts)
101
+
102
+ post('report/v1/ssl-certificates', opts)['reports']
60
103
  end
61
104
 
62
105
  # Revoke an ssl cert
@@ -64,7 +107,7 @@ class Varanus::SSL
64
107
  # @param reason [String] Reason for revoking. Sectigo's API will return an error if it
65
108
  # is blank.
66
109
  def revoke id, reason
67
- post("revoke/#{id}", reason: reason)
110
+ post("ssl/v1/revoke/#{id}", reason: reason)
68
111
  nil
69
112
  end
70
113
 
@@ -96,7 +139,7 @@ class Varanus::SSL
96
139
  comments: opts[:comments].to_s[0, 1024],
97
140
  externalRequester: opts[:external_requester].to_s[0, 512]
98
141
  }
99
- post('enroll', args)['sslId']
142
+ post('ssl/v1/enroll', args)['sslId']
100
143
  end
101
144
 
102
145
  private
@@ -109,39 +152,6 @@ class Varanus::SSL
109
152
  nil
110
153
  end
111
154
 
112
- def check_result result
113
- body = result.body
114
- return unless body.is_a?(Hash)
115
- return if body['code'].nil?
116
-
117
- klass = Varanus::Error
118
- if body['code'] == 0 && body['description'] =~ /process/
119
- klass = Varanus::Error::StillProcessing
120
- end
121
-
122
- raise klass.new(body['code'], body['description'])
123
- end
124
-
125
- def connection
126
- @connection ||= Faraday.new(url: 'https://cert-manager.com/api/ssl/v1',
127
- request: { timeout: 300 }) do |conn|
128
- conn.request :json
129
- conn.response :json, content_type: /\bjson$/
130
-
131
- conn.headers['login'] = @varanus.username
132
- conn.headers['password'] = @varanus.password
133
- conn.headers['customerUri'] = @varanus.customer_uri
134
-
135
- conn.adapter Faraday.default_adapter
136
- end
137
- end
138
-
139
- def get path
140
- result = connection.get(path)
141
- check_result result
142
- result.body
143
- end
144
-
145
155
  def opts_to_cert_type_id opts, csr
146
156
  case opts[:cert_type]
147
157
  when Integer
@@ -153,15 +163,29 @@ class Varanus::SSL
153
163
  end
154
164
  end
155
165
 
156
- def post path, *args
157
- result = connection.post(path, *args)
158
- check_result result
159
- result.body
160
- end
161
-
162
166
  def opts_to_term opts, cert_type_id
163
167
  term = opts[:days]
164
168
  term ||= certificate_types.find { |ct| ct['id'] == cert_type_id }['terms'].min
165
169
  term
166
170
  end
171
+
172
+ def _parse_report_opts user_opts
173
+ api_opts = {}
174
+ user_opts.each do |key, val|
175
+ case key
176
+ when :organizationIds, :certificateRequestSource, :serialNumberFormat
177
+ api_opts[key] = val
178
+ when :from, :to
179
+ api_opts[key] = val.strftime('%Y-%m-%d')
180
+ when :certificateStatus
181
+ api_opts[key] = REPORT_CERT_STATUS[val]
182
+ when :certificateDateAttribute
183
+ api_opts[key] = REPORT_CERT_DATE_ATTR[val]
184
+ else
185
+ raise ArgumentError, "Unknown key: #{key.inspect}"
186
+ end
187
+ end
188
+
189
+ api_opts
190
+ end
167
191
  end
@@ -87,6 +87,8 @@ class Varanus::SSL::CSR
87
87
  @request.public_key.n.num_bytes * 8
88
88
  when OpenSSL::PKey::DSA
89
89
  @request.public_key.p.num_bytes * 8
90
+ when OpenSSL::PKey::EC
91
+ @request.public_key.group.degree
90
92
  else
91
93
  raise "Unknown public key type: #{@request.public_key.class}"
92
94
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Varanus
4
- VERSION = '0.3.0'
4
+ VERSION = '0.6.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: varanus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Dilda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-24 00:00:00.000000000 Z
11
+ date: 2021-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -204,8 +204,12 @@ files:
204
204
  - bin/setup
205
205
  - docker-compose.yml
206
206
  - lib/varanus.rb
207
+ - lib/varanus/dcv.rb
208
+ - lib/varanus/domain.rb
207
209
  - lib/varanus/error.rb
210
+ - lib/varanus/organization.rb
208
211
  - lib/varanus/reports.rb
212
+ - lib/varanus/rest_resource.rb
209
213
  - lib/varanus/ssl.rb
210
214
  - lib/varanus/ssl/csr.rb
211
215
  - lib/varanus/version.rb