localhost 1.1.2 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/localhost/authority.rb +29 -4
- data/lib/localhost/version.rb +1 -1
- metadata +27 -23
- data/.gitignore +0 -13
- data/.rspec +0 -3
- data/.travis.yml +0 -23
- data/Gemfile +0 -11
- data/README.md +0 -120
- data/Rakefile +0 -6
- data/localhost.gemspec +0 -22
- data/media/chrome.png +0 -0
- data/media/safari.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43b262a968bffc41686157f8aeb624e0521827a90e33e73c6611296bd6e73e87
|
4
|
+
data.tar.gz: edef20da4668a9b95afe5c20da1a6d967ab6af0cfb920b8f5359d9c206ca6bee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd194a986200716fcc1989e6048269f399f7b91c4ec7e03c5214dd7e815da067ec854e079abedb1ca55fd0e260a0b787c0436a85e4f849baecb77ae583f9ed06
|
7
|
+
data.tar.gz: 98288d9c362a8d9f7b1fdd23bf5b24c110652cd480eb17a38218e16384155385ecbc87a5e210ea1fa02dd4c210297898dd2dac0fc81d6503ae086a08b1972501
|
data/lib/localhost/authority.rb
CHANGED
@@ -49,8 +49,18 @@ module Localhost
|
|
49
49
|
@store = nil
|
50
50
|
end
|
51
51
|
|
52
|
+
BITS = 1024*2
|
53
|
+
|
54
|
+
def ecdh_key
|
55
|
+
@ecdh_key ||= OpenSSL::PKey::EC.new "prime256v1"
|
56
|
+
end
|
57
|
+
|
58
|
+
def dh_key
|
59
|
+
@dh_key ||= OpenSSL::PKey::DH.new(BITS)
|
60
|
+
end
|
61
|
+
|
52
62
|
def key
|
53
|
-
@key ||= OpenSSL::PKey::RSA.new(
|
63
|
+
@key ||= OpenSSL::PKey::RSA.new(BITS)
|
54
64
|
end
|
55
65
|
|
56
66
|
def key= key
|
@@ -58,7 +68,7 @@ module Localhost
|
|
58
68
|
end
|
59
69
|
|
60
70
|
def name
|
61
|
-
@name ||= OpenSSL::X509::Name.parse("O=Development/CN=#{@hostname}")
|
71
|
+
@name ||= OpenSSL::X509::Name.parse("/O=Development/CN=#{@hostname}")
|
62
72
|
end
|
63
73
|
|
64
74
|
def name= name
|
@@ -102,6 +112,8 @@ module Localhost
|
|
102
112
|
end
|
103
113
|
end
|
104
114
|
|
115
|
+
SERVER_CIPHERS = "EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5".freeze
|
116
|
+
|
105
117
|
def server_context(*args)
|
106
118
|
OpenSSL::SSL::SSLContext.new(*args).tap do |context|
|
107
119
|
context.key = self.key
|
@@ -109,7 +121,20 @@ module Localhost
|
|
109
121
|
|
110
122
|
context.session_id_context = "localhost"
|
111
123
|
|
112
|
-
context.
|
124
|
+
if context.respond_to? :tmp_dh_callback=
|
125
|
+
context.tmp_dh_callback = proc {self.dh_key}
|
126
|
+
end
|
127
|
+
|
128
|
+
if context.respond_to? :ecdh_curves=
|
129
|
+
context.ecdh_curves = 'P-256:P-384:P-521'
|
130
|
+
elsif context.respond_to? :tmp_ecdh_callback=
|
131
|
+
context.tmp_ecdh_callback = proc {self.ecdh_key}
|
132
|
+
end
|
133
|
+
|
134
|
+
context.set_params(
|
135
|
+
ciphers: SERVER_CIPHERS,
|
136
|
+
verify_mode: OpenSSL::SSL::VERIFY_NONE,
|
137
|
+
)
|
113
138
|
end
|
114
139
|
end
|
115
140
|
|
@@ -124,7 +149,7 @@ module Localhost
|
|
124
149
|
end
|
125
150
|
|
126
151
|
def load(path)
|
127
|
-
if File.directory? path
|
152
|
+
if File.directory? path
|
128
153
|
certificate_path = File.join(path, "#{@hostname}.crt")
|
129
154
|
key_path = File.join(path, "#{@hostname}.key")
|
130
155
|
|
data/lib/localhost/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: localhost
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: covered
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,29 +66,20 @@ dependencies:
|
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '3.0'
|
55
|
-
description:
|
69
|
+
description:
|
56
70
|
email:
|
57
|
-
- samuel.williams@oriontransfer.co.nz
|
58
71
|
executables: []
|
59
72
|
extensions: []
|
60
73
|
extra_rdoc_files: []
|
61
74
|
files:
|
62
|
-
- ".gitignore"
|
63
|
-
- ".rspec"
|
64
|
-
- ".travis.yml"
|
65
|
-
- Gemfile
|
66
|
-
- README.md
|
67
|
-
- Rakefile
|
68
75
|
- lib/localhost.rb
|
69
76
|
- lib/localhost/authority.rb
|
70
77
|
- lib/localhost/version.rb
|
71
|
-
- localhost.gemspec
|
72
|
-
- media/chrome.png
|
73
|
-
- media/safari.png
|
74
78
|
homepage: https://github.com/socketry/localhost
|
75
|
-
licenses:
|
79
|
+
licenses:
|
80
|
+
- MIT
|
76
81
|
metadata: {}
|
77
|
-
post_install_message:
|
82
|
+
post_install_message:
|
78
83
|
rdoc_options: []
|
79
84
|
require_paths:
|
80
85
|
- lib
|
@@ -89,9 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
94
|
- !ruby/object:Gem::Version
|
90
95
|
version: '0'
|
91
96
|
requirements: []
|
92
|
-
|
93
|
-
|
94
|
-
signing_key:
|
97
|
+
rubygems_version: 3.1.2
|
98
|
+
signing_key:
|
95
99
|
specification_version: 4
|
96
100
|
summary: Manage a local certificate authority for self-signed localhost development
|
97
101
|
servers.
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
sudo: required
|
3
|
-
dist: xenial
|
4
|
-
cache: bundler
|
5
|
-
|
6
|
-
before_script:
|
7
|
-
- gem update --system
|
8
|
-
- gem install bundler
|
9
|
-
|
10
|
-
matrix:
|
11
|
-
include:
|
12
|
-
- rvm: 2.3
|
13
|
-
- rvm: 2.4
|
14
|
-
- rvm: 2.5
|
15
|
-
- rvm: 2.6
|
16
|
-
- rvm: jruby-head
|
17
|
-
env: JRUBY_OPTS="--debug -X+O"
|
18
|
-
- rvm: ruby-head
|
19
|
-
- rvm: rbx-3
|
20
|
-
allow_failures:
|
21
|
-
- rvm: ruby-head
|
22
|
-
- rvm: jruby-head
|
23
|
-
- rvm: rbx-3
|
data/Gemfile
DELETED
data/README.md
DELETED
@@ -1,120 +0,0 @@
|
|
1
|
-
# Localhost [![Build Status](https://travis-ci.com/socketry/localhost.svg)](https://travis-ci.com/socketry/localhost)
|
2
|
-
|
3
|
-
This gem provides a convenient API for generating per-user self-signed root certificates.
|
4
|
-
|
5
|
-
## Motivation
|
6
|
-
|
7
|
-
HTTP/2 requires SSL in web browsers. If you want to use HTTP/2 for development (and you should), you need to start using URLs like `https://localhost:8080`. In most cases, this requires adding a self-signed certificate to your certificate store (e.g. Keychain on macOS), and storing the private key for the web-server to use.
|
8
|
-
|
9
|
-
I wanted to provide a server-agnostic way of doing this, primarily because I think it makes sense to minimise the amount of junky self-signed keys you add to your certificate store for `localhost`.
|
10
|
-
|
11
|
-
## Installation
|
12
|
-
|
13
|
-
Add this line to your application's Gemfile:
|
14
|
-
|
15
|
-
```ruby
|
16
|
-
gem 'localhost'
|
17
|
-
```
|
18
|
-
|
19
|
-
And then execute:
|
20
|
-
|
21
|
-
$ bundle
|
22
|
-
|
23
|
-
Or install it yourself as:
|
24
|
-
|
25
|
-
$ gem install localhost
|
26
|
-
|
27
|
-
## Usage
|
28
|
-
|
29
|
-
This example shows how to generate a certificate for an SSL secured web server:
|
30
|
-
|
31
|
-
```ruby
|
32
|
-
require 'localhost/authority'
|
33
|
-
require 'socket'
|
34
|
-
|
35
|
-
authority = Localhost::Authority.fetch
|
36
|
-
|
37
|
-
server_thread = Thread.new do
|
38
|
-
server = OpenSSL::SSL::SSLServer.new(TCPServer.new("localhost", 4050), authority.server_context)
|
39
|
-
|
40
|
-
server.listen
|
41
|
-
|
42
|
-
peer = server.accept
|
43
|
-
|
44
|
-
puts "Writing..."
|
45
|
-
peer.flush
|
46
|
-
|
47
|
-
peer.close
|
48
|
-
end
|
49
|
-
|
50
|
-
client = OpenSSL::SSL::SSLSocket.new(TCPSocket.new("localhost", 4050), authority.client_context)
|
51
|
-
|
52
|
-
# Initialize SSL connection
|
53
|
-
client.connect
|
54
|
-
|
55
|
-
puts client.read
|
56
|
-
|
57
|
-
client.close
|
58
|
-
|
59
|
-
server_thread.join
|
60
|
-
```
|
61
|
-
|
62
|
-
If you use Safari to access such a server, it will allow you to add the certificate to your keychain without much work. Once you've done this, you won't need to do it again for any other site when running such a development environment from the same user account.
|
63
|
-
|
64
|
-
### Safari
|
65
|
-
|
66
|
-
If you use this with a web server, when you open the site in Safari:
|
67
|
-
|
68
|
-
![Safari](media/safari.png)
|
69
|
-
|
70
|
-
- Click "View the certificate" to check that it is the correct certificate.
|
71
|
-
- Click "visit this website" which will prompt you to add the certificate to your keychain. Once you've done this, it should work for a long time.
|
72
|
-
|
73
|
-
### Chrome
|
74
|
-
|
75
|
-
If you use this with a web server, when you open the site in Safari:
|
76
|
-
|
77
|
-
![Chrome](media/chrome.png)
|
78
|
-
|
79
|
-
- Click "ADVANCED" to see additional details, including...
|
80
|
-
- Click "Proceed to localhost (unsafe)" which will allow you to use the site for the current browser session.
|
81
|
-
|
82
|
-
### Files
|
83
|
-
|
84
|
-
The certificate and private key are stored in `~/.localhost/`. You can delete them and they will be regenerated. If you added the certificate to your keychain, you'll probably want to delete that too.
|
85
|
-
|
86
|
-
## Contributing
|
87
|
-
|
88
|
-
1. Fork it
|
89
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
90
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
91
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
92
|
-
5. Create new Pull Request
|
93
|
-
|
94
|
-
## See Also
|
95
|
-
|
96
|
-
- [falcon](https://github.com/socketry/falcon) — Uses this `Localhost::Authority` to provide HTTP/2 with minimal configuration for `localhost`.
|
97
|
-
|
98
|
-
## License
|
99
|
-
|
100
|
-
Released under the MIT license.
|
101
|
-
|
102
|
-
Copyright, 2018, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
|
103
|
-
|
104
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
105
|
-
of this software and associated documentation files (the "Software"), to deal
|
106
|
-
in the Software without restriction, including without limitation the rights
|
107
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
108
|
-
copies of the Software, and to permit persons to whom the Software is
|
109
|
-
furnished to do so, subject to the following conditions:
|
110
|
-
|
111
|
-
The above copyright notice and this permission notice shall be included in
|
112
|
-
all copies or substantial portions of the Software.
|
113
|
-
|
114
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
115
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
116
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
117
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
118
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
119
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
120
|
-
THE SOFTWARE.
|
data/Rakefile
DELETED
data/localhost.gemspec
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative "lib/localhost/version"
|
3
|
-
|
4
|
-
Gem::Specification.new do |spec|
|
5
|
-
spec.name = "localhost"
|
6
|
-
spec.version = Localhost::VERSION
|
7
|
-
spec.authors = ["Samuel Williams"]
|
8
|
-
spec.email = ["samuel.williams@oriontransfer.co.nz"]
|
9
|
-
|
10
|
-
spec.summary = "Manage a local certificate authority for self-signed localhost development servers."
|
11
|
-
spec.homepage = "https://github.com/socketry/localhost"
|
12
|
-
|
13
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
14
|
-
f.match(%r{^(test|spec|features)/})
|
15
|
-
end
|
16
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
-
spec.require_paths = ["lib"]
|
18
|
-
|
19
|
-
spec.add_development_dependency "bundler", "~> 1.16"
|
20
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
21
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
22
|
-
end
|
data/media/chrome.png
DELETED
Binary file
|
data/media/safari.png
DELETED
Binary file
|