mini_ca 0.1.0 → 1.0.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 +6 -6
- data/lib/mini_ca/version.rb +1 -1
- data/spec/mini_ca/certificate_spec.rb +7 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b5eb806c9785fd8ce55c117dfe4fc4b018b1531
|
4
|
+
data.tar.gz: 4ac9e96bdc3d9d03d336cd2d6cee9c0c918b7556
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17ec4d452f34a2ef3683886b6613bdd09eb9f90c703e4ac69b9bce1dbd974d009668012a5a148c1121bdbff1893f884ad43f4a8871e4dc1e88a2457fddc12572
|
7
|
+
data.tar.gz: b6a79a95f467bbfcd82745e3ca4c5477d2cee1acc55760e6b0e2b63b059f1f64d99042af7a0b4c453ff5cd7c6b2d6eaea13d55cd371d8cd58f6294b9bf4b7d76
|
data/lib/mini_ca/certificate.rb
CHANGED
@@ -2,7 +2,7 @@ module MiniCa
|
|
2
2
|
class Certificate
|
3
3
|
DIGEST = OpenSSL::Digest::SHA256
|
4
4
|
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :private_key, :x509, :issuer, :ca
|
6
6
|
|
7
7
|
# rubocop:disable ParameterLists
|
8
8
|
def initialize(
|
@@ -18,7 +18,7 @@ module MiniCa
|
|
18
18
|
location: nil,
|
19
19
|
organization: nil
|
20
20
|
)
|
21
|
-
@
|
21
|
+
@private_key = OpenSSL::PKey::RSA.new(2048)
|
22
22
|
@x509 = OpenSSL::X509::Certificate.new
|
23
23
|
@issuer = issuer
|
24
24
|
@ca = ca
|
@@ -27,7 +27,7 @@ module MiniCa
|
|
27
27
|
x509.version = 0x2
|
28
28
|
x509.serial = serial || 0
|
29
29
|
|
30
|
-
x509.public_key =
|
30
|
+
x509.public_key = private_key.public_key
|
31
31
|
|
32
32
|
x509.subject = OpenSSL::X509::Name.new
|
33
33
|
|
@@ -81,7 +81,7 @@ module MiniCa
|
|
81
81
|
|
82
82
|
exts.each { |e| x509.add_extension(e) }
|
83
83
|
|
84
|
-
signing_key = issuer ? issuer.
|
84
|
+
signing_key = issuer ? issuer.private_key : private_key
|
85
85
|
x509.sign signing_key, DIGEST.new
|
86
86
|
end
|
87
87
|
# rubocop:enable ParameterLists
|
@@ -122,8 +122,8 @@ module MiniCa
|
|
122
122
|
bundle.map(&:x509).map(&:to_s).join('')
|
123
123
|
end
|
124
124
|
|
125
|
-
def
|
126
|
-
|
125
|
+
def private_key_pem
|
126
|
+
private_key.to_s
|
127
127
|
end
|
128
128
|
end
|
129
129
|
end
|
data/lib/mini_ca/version.rb
CHANGED
@@ -130,4 +130,11 @@ describe MiniCa::Certificate do
|
|
130
130
|
expect(c.bundle_pem).to end_with(i1.x509_pem)
|
131
131
|
end
|
132
132
|
end
|
133
|
+
|
134
|
+
describe '#private_key_pem' do
|
135
|
+
it 'returns a private key' do
|
136
|
+
c = described_class.new('foo')
|
137
|
+
expect(c.private_key_pem).to include('BEGIN RSA PRIVATE KEY')
|
138
|
+
end
|
139
|
+
end
|
133
140
|
end
|