localhost 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/localhost/authority.rb +38 -20
- data/lib/localhost/version.rb +2 -2
- data/license.md +1 -0
- data.tar.gz.sig +0 -0
- metadata +6 -3
- 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: 42bb902395ea685a7f1d14530439871920afb46b852aa9f6c3bbb8b66d07176a
|
4
|
+
data.tar.gz: 2b63d1af2999cd2ebca0f706bb626654cf765953fbbe1a0a6d4c3b6985482b50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f27728bc1e1593af0db04c176bd99c878958aa662d6902649d6d5cb617034269e641a61d201255be7f8a859a08b3015980b56f28672dc301547f7aa3c6c96fa8
|
7
|
+
data.tar.gz: 66ad2882eef6927aaf6da87280931a81f5928d2cf72bb92a6a10451721465a08b9d51f52a01a1d97847a7019c634499c2cb068ed19401d1e8e713452ec633156
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/localhost/authority.rb
CHANGED
@@ -1,20 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2018-
|
4
|
+
# Copyright, 2018-2024, by Samuel Williams.
|
5
5
|
# Copyright, 2019, by Richard S. Leung.
|
6
6
|
# Copyright, 2021, by Akshay Birajdar.
|
7
7
|
# Copyright, 2021, by Ye Lin Aung.
|
8
8
|
# Copyright, 2023, by Antonio Terceiro.
|
9
9
|
# Copyright, 2023, by Yuuji Yaginuma.
|
10
|
+
# Copyright, 2024, by Colin Shea.
|
10
11
|
|
12
|
+
require 'fileutils'
|
11
13
|
require 'openssl'
|
12
14
|
|
13
15
|
module Localhost
|
14
16
|
# Represents a single public/private key pair for a given hostname.
|
15
17
|
class Authority
|
18
|
+
# Where to store the key pair on the filesystem. This is a subdirectory
|
19
|
+
# of $XDG_STATE_HOME, or ~/.local/state/ when that's not defined.
|
16
20
|
def self.path
|
17
|
-
File.expand_path("
|
21
|
+
File.expand_path("localhost.rb", ENV.fetch("XDG_STATE_HOME", "~/.local/state"))
|
18
22
|
end
|
19
23
|
|
20
24
|
# List all certificate authorities in the given directory:
|
@@ -176,27 +180,27 @@ module Localhost
|
|
176
180
|
end
|
177
181
|
|
178
182
|
def load(path = @root)
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
183
|
+
ensure_authority_path_exists(path)
|
184
|
+
|
185
|
+
certificate_path = File.join(path, "#{@hostname}.crt")
|
186
|
+
key_path = File.join(path, "#{@hostname}.key")
|
187
|
+
|
188
|
+
return false unless File.exist?(certificate_path) and File.exist?(key_path)
|
189
|
+
|
190
|
+
certificate = OpenSSL::X509::Certificate.new(File.read(certificate_path))
|
191
|
+
key = OpenSSL::PKey::RSA.new(File.read(key_path))
|
192
|
+
|
193
|
+
# Certificates with old version need to be regenerated.
|
194
|
+
return false if certificate.version < 2
|
195
|
+
|
196
|
+
@certificate = certificate
|
197
|
+
@key = key
|
198
|
+
|
199
|
+
return true
|
196
200
|
end
|
197
201
|
|
198
202
|
def save(path = @root)
|
199
|
-
|
203
|
+
ensure_authority_path_exists(path)
|
200
204
|
|
201
205
|
lockfile_path = File.join(path, "#{@hostname}.lock")
|
202
206
|
|
@@ -214,5 +218,19 @@ module Localhost
|
|
214
218
|
)
|
215
219
|
end
|
216
220
|
end
|
221
|
+
|
222
|
+
# Ensures that the directory to store the certificate exists. If the legacy
|
223
|
+
# directory (~/.localhost/) exists, it is moved into the new XDG Basedir
|
224
|
+
# compliant directory.
|
225
|
+
def ensure_authority_path_exists(path = @root)
|
226
|
+
old_root = File.expand_path("~/.localhost")
|
227
|
+
|
228
|
+
if File.directory?(old_root) and not File.directory?(path)
|
229
|
+
# Migrates the legacy dir ~/.localhost/ to the XDG compliant directory
|
230
|
+
File.rename(old_root, path)
|
231
|
+
elsif not File.directory?(path)
|
232
|
+
FileUtils.makedirs(path, mode: 0700)
|
233
|
+
end
|
234
|
+
end
|
217
235
|
end
|
218
236
|
end
|
data/lib/localhost/version.rb
CHANGED
data/license.md
CHANGED
@@ -9,6 +9,7 @@ Copyright, 2021, by Ye Lin Aung.
|
|
9
9
|
Copyright, 2022, by Juri Hahn.
|
10
10
|
Copyright, 2023, by Antonio Terceiro.
|
11
11
|
Copyright, 2023, by Yuuji Yaginuma.
|
12
|
+
Copyright, 2024, by Colin Shea.
|
12
13
|
|
13
14
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
14
15
|
of this software and associated documentation files (the "Software"), to deal
|
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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -9,6 +9,7 @@ authors:
|
|
9
9
|
- Ye Lin Aung
|
10
10
|
- Akshay Birajdar
|
11
11
|
- Antonio Terceiro
|
12
|
+
- Colin Shea
|
12
13
|
- Gabriel Sobrinho
|
13
14
|
- Juri Hahn
|
14
15
|
- Richard S. Leung
|
@@ -45,7 +46,7 @@ cert_chain:
|
|
45
46
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
46
47
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
47
48
|
-----END CERTIFICATE-----
|
48
|
-
date: 2024-
|
49
|
+
date: 2024-04-12 00:00:00.000000000 Z
|
49
50
|
dependencies: []
|
50
51
|
description:
|
51
52
|
email:
|
@@ -61,7 +62,9 @@ files:
|
|
61
62
|
homepage: https://github.com/socketry/localhost
|
62
63
|
licenses:
|
63
64
|
- MIT
|
64
|
-
metadata:
|
65
|
+
metadata:
|
66
|
+
documentation_uri: https://socketry.github.io/localhost/
|
67
|
+
source_code_uri: https://github.com/socketry/localhost.git
|
65
68
|
post_install_message:
|
66
69
|
rdoc_options: []
|
67
70
|
require_paths:
|
metadata.gz.sig
CHANGED
Binary file
|