localhost 1.1.3 → 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b86e2157a0bb7ccb760179614cc9a49f2b4301870838f049aa9802a76cb2dec
4
- data.tar.gz: ecb0ee7388befd62714e953f89cf2cdaf1d721bf628384dc9f5d3faf09e0d25a
3
+ metadata.gz: 7a8bb85b8e82b1ceaec73363ba246313ee46da6d47c948ed2b57bfa1f931b51a
4
+ data.tar.gz: 8953521fbcd8eb215ddfaaa59a65b96715c8e69dfb925b0794d1e5e41c204613
5
5
  SHA512:
6
- metadata.gz: 2d8269e428c27e72cbc812d8c3201e0d06fc10e650036245b46e5c2f12f37d871a7bdb49a764d10540ba81f86105791e123381ba42dcb60553a4d88299b811ac
7
- data.tar.gz: 42e81d392df2945a45ec85ffce3e6e3402bc9d2d0e1ad3fd5eef9541102e26ab530abfeb6442d662a8389fea46103bf5112324b9bd5f9478335e7d6cbbdb17e4
6
+ metadata.gz: 16e6781fb5b9caf6180ae68579066d2ab0006fbbb5107d81a6ed475dabeb37a0362ecb67a4e19a7f4d527794e56848c9c367286a1a6424494e0f3bc81cfc9704
7
+ data.tar.gz: 93a1b52e82b6abf55413b9af17f3769bc659cfcc857da9e6a0c9860120137247490abd11d9261d17539f1ef9ef234db29827c3ce07745ac89a0dd1ebad28b2fb
@@ -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(1024*2)
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
@@ -111,8 +121,19 @@ module Localhost
111
121
 
112
122
  context.session_id_context = "localhost"
113
123
 
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
+
114
134
  context.set_params(
115
- ciphers: SERVER_CIPHERS
135
+ ciphers: SERVER_CIPHERS,
136
+ verify_mode: OpenSSL::SSL::VERIFY_NONE,
116
137
  )
117
138
  end
118
139
  end
@@ -128,7 +149,7 @@ module Localhost
128
149
  end
129
150
 
130
151
  def load(path)
131
- if File.directory? path
152
+ if File.directory? path
132
153
  certificate_path = File.join(path, "#{@hostname}.crt")
133
154
  key_path = File.join(path, "#{@hostname}.key")
134
155
 
@@ -148,15 +169,21 @@ module Localhost
148
169
  end
149
170
 
150
171
  def save(path)
151
- File.write(
152
- File.join(path, "#{@hostname}.crt"),
153
- self.certificate.to_pem
154
- )
172
+ lockfile_path = File.join(path, "#{@hostname}.lock")
155
173
 
156
- File.write(
157
- File.join(path, "#{@hostname}.key"),
158
- self.key.to_pem
159
- )
174
+ File.open(lockfile_path, File::RDWR|File::CREAT, 0644) do |lockfile|
175
+ lockfile.flock(File::LOCK_EX)
176
+
177
+ File.write(
178
+ File.join(path, "#{@hostname}.crt"),
179
+ self.certificate.to_pem
180
+ )
181
+
182
+ File.write(
183
+ File.join(path, "#{@hostname}.key"),
184
+ self.key.to_pem
185
+ )
186
+ end
160
187
  end
161
188
  end
162
189
  end
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Localhost
22
- VERSION = "1.1.3"
22
+ VERSION = "1.1.8"
23
23
  end
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.3
4
+ version: 1.1.8
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: 2018-08-19 00:00:00.000000000 Z
11
+ date: 2021-04-24 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: '1.16'
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: '1.16'
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
- rubyforge_project:
93
- rubygems_version: 2.7.7
94
- signing_key:
97
+ rubygems_version: 3.2.3
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
@@ -1,13 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
12
-
13
- /ssl/
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.travis.yml DELETED
@@ -1,19 +0,0 @@
1
- language: ruby
2
- dist: xenial
3
- cache: bundler
4
-
5
- matrix:
6
- include:
7
- - rvm: 2.3.6
8
- - rvm: 2.3
9
- - rvm: 2.4
10
- - rvm: 2.5
11
- - rvm: 2.6
12
- - rvm: jruby-head
13
- env: JRUBY_OPTS="--debug -X+O"
14
- - rvm: ruby-head
15
- - rvm: rbx-3
16
- allow_failures:
17
- - rvm: ruby-head
18
- - rvm: jruby-head
19
- - rvm: rbx-3
data/Gemfile DELETED
@@ -1,13 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in localhost.gemspec
6
- gemspec
7
-
8
- group :development do
9
- gem 'async-io'
10
- gem 'async-rspec'
11
-
12
- gem 'async-process'
13
- end
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
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
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