mini_ca 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mini_ca/certificate.rb +9 -8
- data/lib/mini_ca/version.rb +1 -1
- data/spec/mini_ca/certificate_spec.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06bddcecf2ec2c529177bb69a1eba6976782dc5a
|
4
|
+
data.tar.gz: cf6e2f175bca1fc67a9189d732aa4fd98ff177d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d250121cf10d9be8eb6920cb875da350c69abcb53f027719f15bb524d6d83cdef6070b92f2cf97a94be5d522308e04dc1e8be5c4ee6a904a8d0c01cdb450e889
|
7
|
+
data.tar.gz: 91817dd4578ff71c5822175fccb2538e1f22e85b0b4886bbd82cd18d49781af768df65d1eb4ff8e184f2f77fa2732503c70bf8fbe236b8776d400df3acc8e8c8
|
data/lib/mini_ca/certificate.rb
CHANGED
@@ -16,9 +16,10 @@ module MiniCa
|
|
16
16
|
country: nil,
|
17
17
|
state: nil,
|
18
18
|
location: nil,
|
19
|
-
organization: nil
|
19
|
+
organization: nil,
|
20
|
+
private_key: nil
|
20
21
|
)
|
21
|
-
@private_key = OpenSSL::PKey::RSA.new(2048)
|
22
|
+
@private_key = private_key || OpenSSL::PKey::RSA.new(2048)
|
22
23
|
@x509 = OpenSSL::X509::Certificate.new
|
23
24
|
@issuer = issuer
|
24
25
|
@ca = ca
|
@@ -27,7 +28,7 @@ module MiniCa
|
|
27
28
|
x509.version = 0x2
|
28
29
|
x509.serial = serial || 0
|
29
30
|
|
30
|
-
x509.public_key = private_key.public_key
|
31
|
+
x509.public_key = send(:private_key).public_key
|
31
32
|
|
32
33
|
x509.subject = OpenSSL::X509::Name.new
|
33
34
|
|
@@ -81,7 +82,7 @@ module MiniCa
|
|
81
82
|
|
82
83
|
exts.each { |e| x509.add_extension(e) }
|
83
84
|
|
84
|
-
signing_key = issuer ? issuer.private_key : private_key
|
85
|
+
signing_key = issuer ? issuer.private_key : send(:private_key)
|
85
86
|
x509.sign signing_key, DIGEST.new
|
86
87
|
end
|
87
88
|
# rubocop:enable ParameterLists
|
@@ -111,19 +112,19 @@ module MiniCa
|
|
111
112
|
end
|
112
113
|
|
113
114
|
def x509_pem
|
114
|
-
x509.
|
115
|
+
x509.to_pem
|
115
116
|
end
|
116
117
|
|
117
118
|
def chain_pem
|
118
|
-
chain.map(&:x509).map(&:
|
119
|
+
chain.map(&:x509).map(&:to_pem).join('')
|
119
120
|
end
|
120
121
|
|
121
122
|
def bundle_pem
|
122
|
-
bundle.map(&:x509).map(&:
|
123
|
+
bundle.map(&:x509).map(&:to_pem).join('')
|
123
124
|
end
|
124
125
|
|
125
126
|
def private_key_pem
|
126
|
-
private_key.
|
127
|
+
private_key.to_pem
|
127
128
|
end
|
128
129
|
end
|
129
130
|
end
|
data/lib/mini_ca/version.rb
CHANGED
@@ -52,6 +52,12 @@ describe MiniCa::Certificate do
|
|
52
52
|
.to eq('/CN=x/O=bar')
|
53
53
|
end
|
54
54
|
end
|
55
|
+
|
56
|
+
it 'initializes with a custom private_key' do
|
57
|
+
k = OpenSSL::PKey::RSA.new(512)
|
58
|
+
expect(described_class.new('x', private_key: k).private_key_pem)
|
59
|
+
.to eq(k.to_pem)
|
60
|
+
end
|
55
61
|
end
|
56
62
|
|
57
63
|
context 'CA' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_ca
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Orozco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|