sslserve 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/sslserve +12 -7
- metadata +1 -1
data/bin/sslserve
CHANGED
@@ -6,13 +6,14 @@ require 'openssl'
|
|
6
6
|
require 'base64'
|
7
7
|
require 'optparse'
|
8
8
|
|
9
|
-
version = "0.1.
|
9
|
+
version = "0.1.2"
|
10
10
|
options = {
|
11
11
|
:dir => Dir.pwd,
|
12
12
|
:host => '127.0.0.1',
|
13
13
|
:port => '3443',
|
14
14
|
:name => "localhost",
|
15
15
|
:expire => 1,
|
16
|
+
:user => nil,
|
16
17
|
:pass => nil,
|
17
18
|
:realm => "sslserve realm"
|
18
19
|
}
|
@@ -40,7 +41,11 @@ OptionParser.new do |opts|
|
|
40
41
|
options[:expire] = e
|
41
42
|
end
|
42
43
|
|
43
|
-
opts.on("-
|
44
|
+
opts.on("-U", "--auth PASSWORD", "USERNAME for HTTP Basic Auth. Defaults to disabled") do |u|
|
45
|
+
options[:user] = u
|
46
|
+
end
|
47
|
+
|
48
|
+
opts.on("-P", "--pass PASSWORD", "PASSWORD for HTTP Basic Auth. Defaults to disabled") do |p|
|
44
49
|
options[:pass] = p
|
45
50
|
end
|
46
51
|
|
@@ -80,10 +85,10 @@ pem = Base64.decode64(cert.to_pem.split("\n")[1..-1].join(""))
|
|
80
85
|
sha1_fingerprint = OpenSSL::Digest::SHA1.digest(pem).unpack("H*").first.scan(/../).join(":").upcase
|
81
86
|
md5_fingerprint = OpenSSL::Digest::MD5.digest(pem).unpack("H*").first.scan(/../).join(":").upcase
|
82
87
|
|
83
|
-
if options[:pass]
|
88
|
+
if options[:user] and options[:pass]
|
84
89
|
authenticate = Proc.new do |req, res|
|
85
90
|
WEBrick::HTTPAuth.basic_auth(req, res, '') do |user, pass|
|
86
|
-
user
|
91
|
+
user == options[:user] and pass == options[:pass]
|
87
92
|
end
|
88
93
|
end
|
89
94
|
else
|
@@ -116,9 +121,9 @@ puts " MD5 Certificate fingerprint:"
|
|
116
121
|
puts " #{md5_fingerprint}"
|
117
122
|
puts "\n Certificate expires at #{expires}"
|
118
123
|
if authenticate
|
119
|
-
puts "\n Basic auth realm:
|
120
|
-
puts " Basic auth user: #{
|
121
|
-
puts " Basic auth pass:
|
124
|
+
puts "\n Basic auth realm: #{options[:realm]}"
|
125
|
+
puts " Basic auth user: #{options[:user]}"
|
126
|
+
puts " Basic auth pass: #{options[:pass]}"
|
122
127
|
end
|
123
128
|
puts "\n Further information: https://github.com/zeroXten/sslserve"
|
124
129
|
puts "=============================================================================="
|