WEBrick::HTTPServer and SSL

M

Mike Houghton

As a newbie this might be useful to other newbies...


I needed to run a WEBrick::HTTPServer using SSL.

First thing to do is visit
http://www.eclectica.ca/howto/ssl-cert-howto.php
Just follow the steps in the summary if you are in a hurry.

Once you have the files as described then the following code loads up
the cert and key and runs in SSL mode. It's only demo code but is a
reasonable starting point for running up a browser with an https://...
url.

Firefox 1.5.0.3 and IE 6.0 work fine against it - but for some reason
FireFox 2 has problems - but I'm sure it's just a Firefox config issue.

=============================================================
#!/usr/local/bin/ruby


require 'webrick'
require 'webrick/https'
require 'openssl'


pkey = cert = cert_name = nil
begin
pkey =
OpenSSL::pKey::RSA.new(File.open("/home/mhoughton/sslcert/key.pem").read)
cert =
OpenSSL::X509::Certificate.new(File.open("/home/mhoughton/sslcert/cert.pem").read)
rescue
$stderr.puts "Switching to use self-signed certificate"
cert_name = [ ["C","JP"], ["O","WEBrick.Org"], ["CN", "WWW"] ]
end


s=WEBrick::HTTPServer.new(

:port => 8080,
:Logger => WEBrick::Log::new($stderr, WEBrick::Log::DEBUG),
:DocumentRoot => "/usr/local/webrick/htdocs",
:SSLEnable => true,
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
:SSLCertificate => cert,
:SSLPrivateKey => pkey,
:SSLCertName => cert_name
)
s.start


=============================================================
 
E

Eric Hodel

As a newbie this might be useful to other newbies...


I needed to run a WEBrick::HTTPServer using SSL.

First thing to do is visit
http://www.eclectica.ca/howto/ssl-cert-howto.php
Just follow the steps in the summary if you are in a hurry.

Once you have the files as described then the following code loads up
the cert and key and runs in SSL mode. It's only demo code but is a
reasonable starting point for running up a browser with an https://...
url.

Firefox 1.5.0.3 and IE 6.0 work fine against it - but for some reason
FireFox 2 has problems - but I'm sure it's just a Firefox config
issue.

Define problems.
 
M

Mike Houghton

Eric said:
Define problems.

problem –noun
1. any question or matter involving doubt, uncertainty, or difficulty.
2. a question proposed for solution or discussion.
3. Mathematics. a statement requiring a solution, usually by means of a
mathematical operation or geometric construction.
–adjective
4. difficult to train or guide; unruly: a problem child.
5. Literature. dealing with choices of action difficult either for an
individual or for society at large: a problem play.
 
E

Eric Hodel

problem =96noun

Your flippant answer gives us no way for us to help you sort out your =20=

alleged problems with Firefox, so please stop wasting our time. Thanks.=
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top