sslserve 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/bin/sslserve +12 -7
  2. metadata +1 -1
@@ -6,13 +6,14 @@ require 'openssl'
6
6
  require 'base64'
7
7
  require 'optparse'
8
8
 
9
- version = "0.1.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("-a", "--auth PASSWORD", "PASSWORD for HTTP Basic Auth. Defaults to disabled. Username is the MD5 certificate fingerprint") do |p|
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 and user.upcase.gsub(/[^0-9A-F]/,'') == md5_fingerprint.upcase.gsub(/[^0-9A-F]/,'') && pass == options[:pass]
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: '#{options[:realm]}'"
120
- puts " Basic auth user: #{md5_fingerprint.upcase.gsub(/[^0-9A-F]/,'')}"
121
- puts " Basic auth pass: '#{options[: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 "=============================================================================="
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sslserve
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: