# WEBrick::HTTPServer and SSL

**URL:** <https://www.ruby-forum.com/t/webrick-httpserver-and-ssl/84215>\
**Category:** Ruby\
**Created:** [February 2, 2007, 12:30pm UTC](https://www.ruby-forum.com/t/webrick-httpserver-and-ssl/84215 "2007-02-02T12:30:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ghoti143](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/90db22/32.png) [@ghoti143](https://www.ruby-forum.com/u/ghoti143)\
**Post date:** [February 2, 2007, 12:30pm UTC](https://www.ruby-forum.com/t/webrick-httpserver-and-ssl/84215/1 "2007-02-02T12:30:33Z")

</div>

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

> **[Eclectica](http://www.eclectica.ca/howto/ssl-cert-howto.php)**
>
> How to create web and mail server certificates by becoming a private Root Certificate Authority using the OpenSSL toolkit.

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](http://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

=============================================================

---

<div class="post-metadata">

**Author:** ![ghoti143](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/90db22/32.png) [@ghoti143](https://www.ruby-forum.com/u/ghoti143)\
**Post date:** [February 2, 2007, 7:23pm UTC](https://www.ruby-forum.com/t/webrick-httpserver-and-ssl/84215/2 "2007-02-02T19:23:07Z")

</div>

On Feb 2, 2007, at 03:30, Mike Houghton wrote:

> 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.

---

<div class="post-metadata">

**Author:** ![ghoti143](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/90db22/32.png) [@ghoti143](https://www.ruby-forum.com/u/ghoti143)\
**Post date:** [February 3, 2007, 10:11am UTC](https://www.ruby-forum.com/t/webrick-httpserver-and-ssl/84215/3 "2007-02-03T10:11:42Z")

</div>

Eric H. wrote:

> On Feb 2, 2007, at 03:30, Mike Houghton wrote:
> 
> > 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.

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.

---

<div class="post-metadata">

**Author:** ![ghoti143](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/90db22/32.png) [@ghoti143](https://www.ruby-forum.com/u/ghoti143)\
**Post date:** [February 4, 2007, 1:52am UTC](https://www.ruby-forum.com/t/webrick-httpserver-and-ssl/84215/4 "2007-02-04T01:52:31Z")

</div>

On Feb 3, 2007, at 01:11, Mike Houghton wrote:

> > > FireFox 2 has problems - but I’m sure it’s just a Firefox config  
> > > issue.
> > 
> > Define problems.
> 
> problem –noun

Your flippant answer gives us no way for us to help you sort out your  
alleged problems with Firefox, so please stop wasting our time. Thanks.
