localhost 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/bake/localhost.rb +12 -14
- data/lib/localhost/authority.rb +18 -0
- data/lib/localhost/state.rb +2 -2
- data/lib/localhost/system/darwin.rb +10 -2
- data/lib/localhost/system/linux.rb +32 -4
- data/lib/localhost/version.rb +2 -2
- data/readme.md +5 -0
- data/releases.md +5 -0
- data.tar.gz.sig +0 -0
- metadata +4 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f89b94a723b8a61b6643315b8e80d1c41e8bbba1e40b4ef717712a27f6b9c99e
|
4
|
+
data.tar.gz: 17a0be5aa542d32276375451ed5f3a29a83f838a9a9905a3e451477c8aa45d8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe38188f3a314ad69e4c7bcc03092cf9e2e1efa98570879aef8d52a94d851f310d8884b767aff64a6642b40d4ca04e0dec54ee2e1c75d1158ec6d514cc09e103
|
7
|
+
data.tar.gz: ce8a85d130b0c828170105f177b189fb5417abd1b9b7c00079eb7951fd6c1a82767d74609ccd3fa2fa3b7b5b665eca98feab3aaffb922cc083f560777786357d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/bake/localhost.rb
CHANGED
@@ -13,13 +13,7 @@ end
|
|
13
13
|
#
|
14
14
|
# @returns [Array(Hash)] The certificate and key paths, and the expiry date.
|
15
15
|
def list
|
16
|
-
Localhost::Authority.list.map
|
17
|
-
{
|
18
|
-
certificate_path: authority.certificate_path,
|
19
|
-
key_path: authority.key_path,
|
20
|
-
expires_at: authority.certificate.not_after,
|
21
|
-
}
|
22
|
-
end
|
16
|
+
Localhost::Authority.list.map(&:to_h)
|
23
17
|
end
|
24
18
|
|
25
19
|
# Fetch a local authority by hostname. If the authority does not exist, it will be created.
|
@@ -27,21 +21,25 @@ end
|
|
27
21
|
# @parameter hostname [String] The hostname to fetch.
|
28
22
|
# @returns [Hash] The certificate and key paths, and the expiry date.
|
29
23
|
def fetch(hostname)
|
30
|
-
|
31
|
-
return {
|
32
|
-
certificate_path: authority.certificate_path,
|
33
|
-
key_path: authority.key_path,
|
34
|
-
expires_at: authority.certificate.not_after,
|
35
|
-
}
|
36
|
-
end
|
24
|
+
Localhost::Authority.fetch(hostname)
|
37
25
|
end
|
38
26
|
|
27
|
+
# Install a certificate into the system trust store.
|
28
|
+
# @parameter name [String] The name of the issuer to install, or nil for the default issuer.
|
39
29
|
def install(name: nil)
|
40
30
|
issuer = Localhost::Issuer.fetch(name)
|
41
31
|
|
32
|
+
$stderr.puts "Installing certificate for #{issuer.subject}..."
|
42
33
|
Localhost::System.current.install(issuer.certificate_path)
|
34
|
+
|
35
|
+
return nil
|
43
36
|
end
|
44
37
|
|
38
|
+
# Delete all local authorities.
|
45
39
|
def purge
|
40
|
+
$stderr.puts "Purging localhost state..."
|
41
|
+
|
46
42
|
Localhost::State.purge
|
43
|
+
|
44
|
+
return nil
|
47
45
|
end
|
data/lib/localhost/authority.rb
CHANGED
@@ -242,5 +242,23 @@ module Localhost
|
|
242
242
|
|
243
243
|
return true
|
244
244
|
end
|
245
|
+
|
246
|
+
# @returns A hash representation of the authority's certificate details.
|
247
|
+
def to_h
|
248
|
+
{
|
249
|
+
hostname: @hostname,
|
250
|
+
certificate_path: certificate_path,
|
251
|
+
key_path: key_path,
|
252
|
+
expires_at: certificate.not_after,
|
253
|
+
}
|
254
|
+
end
|
255
|
+
|
256
|
+
def as_json(...)
|
257
|
+
self.to_h
|
258
|
+
end
|
259
|
+
|
260
|
+
def to_json(...)
|
261
|
+
self.as_json.to_json(...)
|
262
|
+
end
|
245
263
|
end
|
246
264
|
end
|
data/lib/localhost/state.rb
CHANGED
@@ -13,13 +13,21 @@ module Localhost
|
|
13
13
|
def self.install(certificate)
|
14
14
|
login_keychain = File.expand_path("~/Library/Keychains/login.keychain-db")
|
15
15
|
|
16
|
-
system(
|
16
|
+
success = system(
|
17
17
|
"security", "add-trusted-cert",
|
18
18
|
"-d", "-r", "trustRoot",
|
19
19
|
"-k", login_keychain,
|
20
20
|
certificate
|
21
21
|
)
|
22
|
+
|
23
|
+
if success
|
24
|
+
$stderr.puts "Installed certificate to #{login_keychain}"
|
25
|
+
|
26
|
+
return true
|
27
|
+
else
|
28
|
+
raise "Failed to install certificate: #{certificate}"
|
29
|
+
end
|
22
30
|
end
|
23
31
|
end
|
24
32
|
end
|
25
|
-
end
|
33
|
+
end
|
@@ -7,16 +7,44 @@ module Localhost
|
|
7
7
|
module System
|
8
8
|
# Linux specific system operations.
|
9
9
|
module Linux
|
10
|
+
# This appears to be the standard path for the system trust store on many Linux distributions.
|
11
|
+
ANCHORS_PATH = "/etc/ca-certificates/trust-source/anchors/"
|
12
|
+
UPDATE_CA_TRUST = "update-ca-trust"
|
13
|
+
|
14
|
+
# This is an older method for systems that do not use `update-ca-trust`.
|
15
|
+
LOCAL_CERTIFICATES_PATH = "/usr/local/share/ca-certificates/"
|
16
|
+
UPDATE_CA_CERTIFICATES = "update-ca-certificates"
|
17
|
+
|
10
18
|
# Install a certificate into the system trust store.
|
11
19
|
#
|
12
20
|
# @parameter certificate [String] The path to the certificate file.
|
13
21
|
def self.install(certificate)
|
14
22
|
filename = File.basename(certificate)
|
15
|
-
|
23
|
+
command = nil
|
16
24
|
|
17
|
-
|
18
|
-
|
25
|
+
if File.exist?(ANCHORS_PATH)
|
26
|
+
# For systems using `update-ca-trust`.
|
27
|
+
destination = File.join(ANCHORS_PATH, filename)
|
28
|
+
command = UPDATE_CA_TRUST
|
29
|
+
elsif File.exist?(LOCAL_CERTIFICATES_PATH)
|
30
|
+
# For systems using `update-ca-certificates`.
|
31
|
+
destination = File.join(LOCAL_CERTIFICATES_PATH, filename)
|
32
|
+
command = UPDATE_CA_CERTIFICATES
|
33
|
+
else
|
34
|
+
raise "No known system trust store found. Please install the certificate manually."
|
35
|
+
end
|
36
|
+
|
37
|
+
success = system("sudo", "cp", certificate, destination)
|
38
|
+
success &= system("sudo", command)
|
39
|
+
|
40
|
+
if success
|
41
|
+
$stderr.puts "Installed certificate to #{destination}"
|
42
|
+
|
43
|
+
return true
|
44
|
+
else
|
45
|
+
raise "Failed to install certificate: #{certificate}"
|
46
|
+
end
|
19
47
|
end
|
20
48
|
end
|
21
49
|
end
|
22
|
-
end
|
50
|
+
end
|
data/lib/localhost/version.rb
CHANGED
data/readme.md
CHANGED
@@ -22,6 +22,11 @@ Please see the [project documentation](https://socketry.github.io/localhost/) fo
|
|
22
22
|
|
23
23
|
Please see the [project releases](https://socketry.github.io/localhost/releases/index) for all releases.
|
24
24
|
|
25
|
+
### v1.6.0
|
26
|
+
|
27
|
+
- Add support for `update-ca-trust` on Linux sytems.
|
28
|
+
- Better command output.
|
29
|
+
|
25
30
|
### v1.4.0
|
26
31
|
|
27
32
|
- Add `localhost:purge` to delete all certificates.
|
data/releases.md
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: localhost
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -46,7 +46,7 @@ cert_chain:
|
|
46
46
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
47
47
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
48
48
|
-----END CERTIFICATE-----
|
49
|
-
date:
|
49
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
50
50
|
dependencies: []
|
51
51
|
executables: []
|
52
52
|
extensions: []
|
@@ -77,14 +77,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
77
|
requirements:
|
78
78
|
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version: '3.
|
80
|
+
version: '3.2'
|
81
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
83
|
- - ">="
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
|
-
rubygems_version: 3.6.
|
87
|
+
rubygems_version: 3.6.7
|
88
88
|
specification_version: 4
|
89
89
|
summary: Manage a local certificate authority for self-signed localhost development
|
90
90
|
servers.
|
metadata.gz.sig
CHANGED
Binary file
|