sslserve 0.0.1
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.
- data/bin/sslserve +77 -0
- metadata +47 -0
data/bin/sslserve
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'webrick'
|
4
|
+
require 'webrick/https'
|
5
|
+
require 'openssl'
|
6
|
+
require 'optparse'
|
7
|
+
|
8
|
+
version = "0.0.1"
|
9
|
+
options = {
|
10
|
+
:dir => Dir.pwd,
|
11
|
+
:host => '127.0.0.1',
|
12
|
+
:port => '3443',
|
13
|
+
:name => "localhost",
|
14
|
+
:expire => 1
|
15
|
+
}
|
16
|
+
|
17
|
+
OptionParser.new do |opts|
|
18
|
+
opts.banner = "Usage sslserve [options]"
|
19
|
+
|
20
|
+
opts.on("-d", "--dir DIR", "Directory to serve files from. Defaults to pwd") do |d|
|
21
|
+
options[:dir] = d
|
22
|
+
end
|
23
|
+
|
24
|
+
opts.on("-l", "--listen IP", "IP address bind to. Defaults to #{options[:host]}") do |l|
|
25
|
+
options[:host] = l
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on("-p", "--port PORT", "PORT to listen on. Defaults to #{options[:port]}") do |p|
|
29
|
+
options[:port] = p
|
30
|
+
end
|
31
|
+
|
32
|
+
opts.on("-n", "--name NAME", "NAME for SSL certificate. Defaults to #{options[:name]}") do |n|
|
33
|
+
options[:name] = n
|
34
|
+
end
|
35
|
+
|
36
|
+
opts.on("-e", "--expires HOURS", "Certificate expires in HOURS hours. Defaults to #{options[:expires]}") do |e|
|
37
|
+
options[:expire] = e
|
38
|
+
end
|
39
|
+
|
40
|
+
opts.on("-h", "--help", "Show this message") do
|
41
|
+
puts opts
|
42
|
+
exit
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on("-v", "--version", "Show version") do
|
46
|
+
puts "Version #{version}"
|
47
|
+
exit
|
48
|
+
end
|
49
|
+
|
50
|
+
end.parse!
|
51
|
+
|
52
|
+
key = OpenSSL::PKey::RSA.new 2048
|
53
|
+
|
54
|
+
name = OpenSSL::X509::Name.parse "CN=#{options[:name]}"
|
55
|
+
|
56
|
+
cert = OpenSSL::X509::Certificate.new
|
57
|
+
cert.version = 3
|
58
|
+
cert.serial = 0
|
59
|
+
cert.not_before = Time.now
|
60
|
+
cert.not_after = Time.now + (options[:expire] * 3600)
|
61
|
+
cert.public_key = key.public_key
|
62
|
+
cert.subject = name
|
63
|
+
cert.issuer = name
|
64
|
+
cert.sign key, OpenSSL::Digest::SHA1.new
|
65
|
+
|
66
|
+
server = WEBrick::HTTPServer.new(
|
67
|
+
:BindAddress => options[:host],
|
68
|
+
:Port => options[:port],
|
69
|
+
:DocumentRoot => options[:dir],
|
70
|
+
:SSLEnable => true,
|
71
|
+
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
|
72
|
+
:SSLPrivateKey => key,
|
73
|
+
:SSLCertificate => cert,
|
74
|
+
:SSLCertName => [[options[:name], WEBrick::Utils::getservername]],
|
75
|
+
)
|
76
|
+
Signal.trap('INT') { server.shutdown }
|
77
|
+
server.start
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sslserve
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Fraser Scott
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-08-14 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Serve a local directory using this SSL webserver.
|
15
|
+
email: fraser.scott@gmail.com
|
16
|
+
executables:
|
17
|
+
- sslserve
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- bin/sslserve
|
22
|
+
homepage: http://rubygems.org/gems/sslserve
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 1.8.25
|
44
|
+
signing_key:
|
45
|
+
specification_version: 3
|
46
|
+
summary: Simple SSL web server
|
47
|
+
test_files: []
|