easyrsa 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/easyrsa.rb +1 -0
- data/lib/easyrsa/cli.rb +27 -0
- data/lib/easyrsa/dh.rb +24 -0
- data/lib/easyrsa/version.rb +1 -1
- data/spec/easyrsa/05_dh_spec.rb +23 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5867f7b266b3dc21da5099fc19bc412d55038e9d
|
4
|
+
data.tar.gz: 9c51aff5109ee8160b3b4a876bb553b1c979a275
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3a47654d291560264b4d886a2ba9219fc81ca05847c517ee1230f1391d17c23795a21e43f15bdfbc854d9f7d38dd0525b0dc0f717af9a7f8ace95b301d6cadd
|
7
|
+
data.tar.gz: 55053569d0743c54832d75ef61a862b3a6cacca2caf7b933d55322a4f197e53bf91cb196b290359130fb793152bf2a87d956b2a42bb2c356914991587e20ded6
|
data/lib/easyrsa.rb
CHANGED
data/lib/easyrsa/cli.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'paint'
|
2
|
+
|
3
|
+
module EasyRSA
|
4
|
+
module CLI
|
5
|
+
|
6
|
+
def self.success(message)
|
7
|
+
puts " #{Paint['[✓]', :bright, :green]} #{Paint[message, :bright, :white]}"
|
8
|
+
exit!
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.info(message)
|
12
|
+
puts " #{Paint['[i]', :bright, :blue]} #{Paint[message, :bright, :white]}"
|
13
|
+
exit!
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.warning(message)
|
17
|
+
puts " #{Paint['[!]', :bright, :orange]} #{Paint[message, :bright, :white]}"
|
18
|
+
exit!
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.fatal(message)
|
22
|
+
puts " #{Paint['[x]', :bright, :red]} #{Paint[message, :bright, :white]}"
|
23
|
+
exit!
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
data/lib/easyrsa/dh.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module EasyRSA
|
2
|
+
class DH
|
3
|
+
|
4
|
+
class BitLengthToWeak < RuntimeError; end
|
5
|
+
class MissingParameter < RuntimeError; end
|
6
|
+
|
7
|
+
def initialize(bits=1024, &block)
|
8
|
+
# Generate DH
|
9
|
+
if bits < 1024
|
10
|
+
raise EasyRSA::DH::BitLengthToWeak,
|
11
|
+
"Please select a bit length greater than 2048. Default is 4096. You chose '#{bits}'"
|
12
|
+
end
|
13
|
+
@dh = OpenSSL::PKey::DH.new(bits)
|
14
|
+
|
15
|
+
instance_eval(&block) if block_given?
|
16
|
+
end
|
17
|
+
|
18
|
+
def generate
|
19
|
+
dh = @dh.generate_key!
|
20
|
+
dh.to_pem
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
data/lib/easyrsa/version.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe EasyRSA::DH, 'Should' do
|
4
|
+
|
5
|
+
it 'should not throw error when calling new' do
|
6
|
+
expect {
|
7
|
+
EasyRSA::DH.new
|
8
|
+
}.to_not raise_error
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'throw error when bit length is too weak' do
|
12
|
+
expect {
|
13
|
+
EasyRSA::DH.new 512
|
14
|
+
}.to raise_error(EasyRSA::DH::BitLengthToWeak)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should export a real dh param' do
|
18
|
+
dh = EasyRSA::DH.new
|
19
|
+
output = dh.generate
|
20
|
+
expect(output).to include('BEGIN DH PARAMETERS')
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easyrsa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Mackintosh
|
@@ -111,7 +111,9 @@ files:
|
|
111
111
|
- lib/easyrsa.rb
|
112
112
|
- lib/easyrsa/ca.rb
|
113
113
|
- lib/easyrsa/certificate.rb
|
114
|
+
- lib/easyrsa/cli.rb
|
114
115
|
- lib/easyrsa/config.rb
|
116
|
+
- lib/easyrsa/dh.rb
|
115
117
|
- lib/easyrsa/revoke.rb
|
116
118
|
- lib/easyrsa/version.rb
|
117
119
|
- spec/cacert.pem
|
@@ -120,6 +122,7 @@ files:
|
|
120
122
|
- spec/easyrsa/02_certificate_spec.rb
|
121
123
|
- spec/easyrsa/03_ca_spec.rb
|
122
124
|
- spec/easyrsa/04_revocation_spec.rb
|
125
|
+
- spec/easyrsa/05_dh_spec.rb
|
123
126
|
- spec/spec_helper.rb
|
124
127
|
homepage: http://github.com/mikemackintosh/ruby-easyrsa
|
125
128
|
licenses:
|
@@ -152,4 +155,5 @@ test_files:
|
|
152
155
|
- spec/easyrsa/02_certificate_spec.rb
|
153
156
|
- spec/easyrsa/03_ca_spec.rb
|
154
157
|
- spec/easyrsa/04_revocation_spec.rb
|
158
|
+
- spec/easyrsa/05_dh_spec.rb
|
155
159
|
- spec/spec_helper.rb
|