varanus 0.3.1 → 0.7.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: 89ed4dafd7bacfa4ef69c04cb02511a32779cde9013a1448db944ba46465e823
4
- data.tar.gz: 3e04df3f49b583e88b653c0079a94b890bb139eddc5200ea80f61d8181f5d81a
3
+ metadata.gz: 407818df56229b879c4d63d6624b783a8ff2dc330d06142e2d3c7f2733d575a9
4
+ data.tar.gz: 73391e43eb491768ba78da494f67ebdc084ee8ed4bee49fff26566aa85d2a7da
5
5
  SHA512:
6
- metadata.gz: e48bee6b67a987b02228e60c38ef23e5aefbe948cf689db1523ba57b22cbc96d15a5c222c8f71419fa180feeb4aac4764512cea4c6056352bb1e80807ef28b3b
7
- data.tar.gz: '08972545063bcf545370cbf385c9fd60f8d61797de4f8423af3c61b1560b99346a7591f451371b59155661fc11741490bcbeab312ad51b7985926c94c81f6585'
6
+ metadata.gz: e69b04ebf9d7e647cce77c666337f318ba18b0d17ad14c7b7a072786e51750b66c2762bf5c88be9b169393c099edc9ac50c4185b6b1455423b125b131a9f2c35
7
+ data.tar.gz: 303f464f0bced6f740df4b24f366a4427b4529b46063e594d293641af56dfcbe1f054f1b2d7b473321762bd2d5ae74525035a3325decc436ece221567e4d6a50
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.7.0 (2020-02-03)
2
+ * Add Varanus::Domain#report
3
+
4
+ ### Version 0.6.0 (2020-02-01)
5
+ * Add Varanus::SSL#report
6
+ * Varanus::Reports (Varanus#reports) is now deprecated.
7
+
8
+ ### Version 0.5.1 (2021-01-28)
9
+ * Varanus::SSL::CSR - support EC certs
10
+
11
+ ### Version 0.5.0 (2021-01-26)
12
+ * Add Varanus::Domain
13
+ * Add Varanus::SSL#list and Varanus::SSL#info
14
+ * Add Varanus::Organization
15
+
16
+ ### 0.4.0 (2021-01-06)
17
+ * Add Varanus::DCV
18
+
1
19
  ### 0.3.1 (2020-10-14)
2
20
  * Fix issue when Sectigo reports two identical '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.1)
4
+ varanus (0.7.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,46 @@
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
+
43
+ def report
44
+ post('report/v1/domains', {})['reports']
45
+ end
46
+ 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#report 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]
@@ -27,7 +39,7 @@ class Varanus::SSL
27
39
  # Certificate types that can be used to sign a cert
28
40
  # @return [Array<Hash>]
29
41
  def certificate_types
30
- @certificate_types ||= get('types')
42
+ @certificate_types ||= get('ssl/v1/types')
31
43
  end
32
44
 
33
45
  # Return Array of certificate types based on standard sorting.
@@ -57,7 +69,37 @@ class Varanus::SSL
57
69
  # @raise [Varanus::Error::StillProcessing] Cert is still being signed
58
70
  # @return [String] Certificate
59
71
  def collect id, type = 'x509'
60
- 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']
61
103
  end
62
104
 
63
105
  # Revoke an ssl cert
@@ -65,7 +107,7 @@ class Varanus::SSL
65
107
  # @param reason [String] Reason for revoking. Sectigo's API will return an error if it
66
108
  # is blank.
67
109
  def revoke id, reason
68
- post("revoke/#{id}", reason: reason)
110
+ post("ssl/v1/revoke/#{id}", reason: reason)
69
111
  nil
70
112
  end
71
113
 
@@ -97,7 +139,7 @@ class Varanus::SSL
97
139
  comments: opts[:comments].to_s[0, 1024],
98
140
  externalRequester: opts[:external_requester].to_s[0, 512]
99
141
  }
100
- post('enroll', args)['sslId']
142
+ post('ssl/v1/enroll', args)['sslId']
101
143
  end
102
144
 
103
145
  private
@@ -110,39 +152,6 @@ class Varanus::SSL
110
152
  nil
111
153
  end
112
154
 
113
- def check_result result
114
- body = result.body
115
- return unless body.is_a?(Hash)
116
- return if body['code'].nil?
117
-
118
- klass = Varanus::Error
119
- if body['code'] == 0 && body['description'] =~ /process/
120
- klass = Varanus::Error::StillProcessing
121
- end
122
-
123
- raise klass.new(body['code'], body['description'])
124
- end
125
-
126
- def connection
127
- @connection ||= Faraday.new(url: 'https://cert-manager.com/api/ssl/v1',
128
- request: { timeout: 300 }) do |conn|
129
- conn.request :json
130
- conn.response :json, content_type: /\bjson$/
131
-
132
- conn.headers['login'] = @varanus.username
133
- conn.headers['password'] = @varanus.password
134
- conn.headers['customerUri'] = @varanus.customer_uri
135
-
136
- conn.adapter Faraday.default_adapter
137
- end
138
- end
139
-
140
- def get path
141
- result = connection.get(path)
142
- check_result result
143
- result.body
144
- end
145
-
146
155
  def opts_to_cert_type_id opts, csr
147
156
  case opts[:cert_type]
148
157
  when Integer
@@ -154,15 +163,29 @@ class Varanus::SSL
154
163
  end
155
164
  end
156
165
 
157
- def post path, *args
158
- result = connection.post(path, *args)
159
- check_result result
160
- result.body
161
- end
162
-
163
166
  def opts_to_term opts, cert_type_id
164
167
  term = opts[:days]
165
168
  term ||= certificate_types.find { |ct| ct['id'] == cert_type_id }['terms'].min
166
169
  term
167
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
168
191
  end
@@ -28,7 +28,7 @@ class Varanus::SSL::CSR
28
28
  request.add_attribute names_to_san_attribute(names)
29
29
  request.public_key = key.public_key
30
30
 
31
- request.sign(key, OpenSSL::Digest::SHA256.new)
31
+ request.sign(key, OpenSSL::Digest.new('SHA256'))
32
32
 
33
33
  [key, Varanus::SSL::CSR.new(request)]
34
34
  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.1'
4
+ VERSION = '0.7.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.1
4
+ version: 0.7.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-10-14 00:00:00.000000000 Z
11
+ date: 2021-02-03 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