certmeister 2.1.0 → 2.2.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
  SHA1:
3
- metadata.gz: 6cc20cbf2bb5c2b4b721280da39d1f83ca04ac0a
4
- data.tar.gz: aa0e73207c9f71d79ee4ebdf69df41c65dd47829
3
+ metadata.gz: 799bbad30dae1a1c0f05c7e3ba59dc4b3cc47467
4
+ data.tar.gz: 447321524cd2661a7f439d5c19fa056efbc699b5
5
5
  SHA512:
6
- metadata.gz: 68c617c0234008b6900ddedc66a6ac08a2a5d296e46a8bf1583c5f5aa059b5c827c3f6060908920a7c9862de8b02faa2f924b7693ea6e820266784340b2e4248
7
- data.tar.gz: 37bd6723f00a8defd6121d50bcb77c01e881e54c543abe408cbdc2f2fb561863160d9c472ea666cb01fb7bded26ba049392ba96d55e9a2769dbc2e754c3aaf07
6
+ metadata.gz: c98b95cad7ff3960438ac4e8f1a4c73d5458f6774a3743a77694f85fbae21ba39be424176961276b243f7c51d703d4bf5c5cb646f3a515881eb5d7c631db1036
7
+ data.tar.gz: bd53076b8e6b89f3ea3bcc493a5565698aa399e36cac58aa534e7d777f0f3a7071d99b5ff7e4c5dd2a490348ea973390a524928df420abc9a245da0af1044bf6
data/Rakefile CHANGED
@@ -1,4 +1,6 @@
1
1
  require "rspec/core/rake_task"
2
+
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
2
4
  require "certmeister/version"
3
5
 
4
6
  desc 'Build gem into the pkg directory'
@@ -0,0 +1,12 @@
1
+ -----BEGIN CERTIFICATE REQUEST-----
2
+ MIIBrzCCARgCAQAwbzELMAkGA1UEBhMCWkExFTATBgNVBAgMDFdlc3Rlcm4gQ2Fw
3
+ ZTESMBAGA1UEBwwJQ2FwZSBUb3duMRgwFgYDVQQKDA9IZXR6bmVyIFBUWSBMdGQx
4
+ GzAZBgNVBAMMEmF4bC5oZXR6bmVyLmFmcmljYTCBnzANBgkqhkiG9w0BAQEFA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HyPpP7j9/2k6CtsGAtVv
26
+ qPOTJbxnOfwRDfbyDLWBoqHNxmfhq3KtE6ktVxyP9hUyGnAf8yAn3zaDx4V980N6
27
+ 9FNkBniZB+Y=
28
+ -----END CERTIFICATE REQUEST-----
@@ -0,0 +1,46 @@
1
+ require 'certmeister/policy/response'
2
+ require 'openssl'
3
+
4
+ module Certmeister
5
+
6
+ module Policy
7
+
8
+ class KeyBits
9
+
10
+ DEFAULT_MIN_KEY_BITS = 4096
11
+
12
+ attr_reader :min_key_bits
13
+
14
+ def initialize(min_key_bits = DEFAULT_MIN_KEY_BITS)
15
+ validate_min_key_bits(min_key_bits)
16
+ @min_key_bits = min_key_bits
17
+ end
18
+
19
+ def authenticate(request)
20
+ if not request[:pem]
21
+ Certmeister::Policy::Response.new(false, "missing pem")
22
+ else
23
+ cert = OpenSSL::X509::Request.new(request[:pem])
24
+ pkey = cert.public_key
25
+ kbits = pkey.n.num_bytes * 8
26
+ if kbits < @min_key_bits
27
+ Certmeister::Policy::Response.new(false, "weak key")
28
+ else
29
+ Certmeister::Policy::Response.new(true, nil)
30
+ end
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def validate_min_key_bits(min_key_bits)
37
+ unless min_key_bits.is_a?(Integer)
38
+ raise ArgumentError.new("invalid minimum key size")
39
+ end
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+
46
+ end
@@ -1,5 +1,5 @@
1
1
  module Certmeister
2
2
 
3
- VERSION = '2.1.0' unless defined?(VERSION)
3
+ VERSION = '2.2.0' unless defined?(VERSION)
4
4
 
5
5
  end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ require 'certmeister/policy/key_bits'
4
+
5
+ describe Certmeister::Policy::KeyBits do
6
+
7
+ subject { Certmeister::Policy::KeyBits.new(4096) }
8
+
9
+ it "may be configured with a minimum key size in bits" do
10
+ expect { Certmeister::Policy::KeyBits.new("hamster") }.to raise_error(ArgumentError, "invalid minimum key size")
11
+ expect { Certmeister::Policy::KeyBits.new(4096) }.to_not raise_error
12
+ end
13
+
14
+ it "defaults to #{Certmeister::Policy::KeyBits::DEFAULT_MIN_KEY_BITS} bits minimum key size" do
15
+ expect(described_class.new.min_key_bits).to eql Certmeister::Policy::KeyBits::DEFAULT_MIN_KEY_BITS
16
+ end
17
+
18
+ it "demands a request" do
19
+ expect { subject.authenticate }.to raise_error(ArgumentError)
20
+ end
21
+
22
+ it "refuses to authenticate a request with a missing pem" do
23
+ response = subject.authenticate({anything: 'something'})
24
+ expect(response).to_not be_authenticated
25
+ expect(response.error).to eql "missing pem"
26
+ end
27
+
28
+ it "refuses to authenticate an invalid request" do
29
+ pem = File.read('fixtures/kbits_1024.csr')
30
+ response = subject.authenticate({pem: pem})
31
+ expect(response).to_not be_authenticated
32
+ expect(response.error).to eql "weak key"
33
+ end
34
+
35
+ it "refuses to authenticate a request for a key with too few bits" do
36
+ pem = File.read('fixtures/kbits_1024.csr')
37
+ response = subject.authenticate({pem: pem})
38
+ expect(response).to_not be_authenticated
39
+ expect(response.error).to eql "weak key"
40
+ end
41
+
42
+ it "authenticates a request for a key with sufficient bits" do
43
+ pem = File.read('fixtures/kbits_4096.csr')
44
+ response = subject.authenticate({pem: pem})
45
+ expect(response).to be_authenticated
46
+ end
47
+
48
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: certmeister
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sheldon Hearn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-28 00:00:00.000000000 Z
11
+ date: 2016-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,6 +78,8 @@ files:
78
78
  - fixtures/client.crt
79
79
  - fixtures/client.csr
80
80
  - fixtures/client.key
81
+ - fixtures/kbits_1024.csr
82
+ - fixtures/kbits_4096.csr
81
83
  - lib/certmeister.rb
82
84
  - lib/certmeister/base.rb
83
85
  - lib/certmeister/config.rb
@@ -90,6 +92,7 @@ files:
90
92
  - lib/certmeister/policy/existing.rb
91
93
  - lib/certmeister/policy/fcrdns.rb
92
94
  - lib/certmeister/policy/ip.rb
95
+ - lib/certmeister/policy/key_bits.rb
93
96
  - lib/certmeister/policy/noop.rb
94
97
  - lib/certmeister/policy/psk.rb
95
98
  - lib/certmeister/policy/response.rb
@@ -108,6 +111,7 @@ files:
108
111
  - spec/certmeister/policy/existing_spec.rb
109
112
  - spec/certmeister/policy/fcrdns_spec.rb
110
113
  - spec/certmeister/policy/ip_spec.rb
114
+ - spec/certmeister/policy/key_bits_spec.rb
111
115
  - spec/certmeister/policy/noop_spec.rb
112
116
  - spec/certmeister/policy/psk_spec.rb
113
117
  - spec/certmeister/policy/response_spec.rb
@@ -139,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
143
  version: '0'
140
144
  requirements: []
141
145
  rubyforge_project:
142
- rubygems_version: 2.4.5
146
+ rubygems_version: 2.5.1
143
147
  signing_key:
144
148
  specification_version: 4
145
149
  summary: Conditionally autosigning certificate authority.
@@ -154,6 +158,7 @@ test_files:
154
158
  - spec/certmeister/policy/existing_spec.rb
155
159
  - spec/certmeister/policy/fcrdns_spec.rb
156
160
  - spec/certmeister/policy/ip_spec.rb
161
+ - spec/certmeister/policy/key_bits_spec.rb
157
162
  - spec/certmeister/policy/noop_spec.rb
158
163
  - spec/certmeister/policy/psk_spec.rb
159
164
  - spec/certmeister/policy/response_spec.rb