|
A collection of useful facts by Joel Williams. Adelaide denizen. Computer tinkerer. Former terrestrial ecology student of Flinders University. PhD candidate at ANU. Editor for freshmeat.net. Adelaide University Mountain Club member and outdoor enthusiast. Occasional networking go-to guy. Contact me by email at joel at this domain. |
Simple HTTPS ServerI'd forgotten a password, but it was saved in my Safari Autofill thing, which is encrypted. I thought I'd snag it using form submissions. Because the site was HTTPS, I needed to have an appropriate server rather than just sniffing network traffic. I could have modified the Apache config but this seemed more troublesome than writing a program to do it. Hacked together from a few sources. require 'webrick'
require 'webrick/https'
OPTIONS = {
:port => 443,
:server_root => '/Library/WebServer/Documents/'
}
server = WEBrick::HTTPServer.new(:Port => OPTIONS[:port].to_i,
:SSLEnable => true,
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
:SSLCertName => [ [ "CN", WEBrick::Utils::getservername ] ],
:DocumentRoot => OPTIONS[:server_root]
)
class PostDumper < WEBrick::HTTPServlet::AbstractServlet
# Reload file for each request, instantly
# updating the server with code changes
# without needing a restart.
=begin
def PostDumper.get_instance( config, *options )
load __FILE__
PostDumper.new config, *options
end
=end
# cf. http://www.hiveminds.co.uk/node/244, published under the
# GNU Free Documentation License, http://www.gnu.org/copyleft/fdl.html
@@instance = nil
@@instance_creation_mutex = Mutex.new
def self.get_instance(config, *options)
#pp @@instance
@@instance_creation_mutex.synchronize {
|