# Implementing HTTPS with WEBrick?

**URL:** <https://www.ruby-forum.com/t/implementing-https-with-webrick/62003>\
**Category:** Rails\
**Created:** [May 30, 2006, 6:12pm UTC](https://www.ruby-forum.com/t/implementing-https-with-webrick/62003 "2006-05-30T18:12:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [May 30, 2006, 6:12pm UTC](https://www.ruby-forum.com/t/implementing-https-with-webrick/62003/1 "2006-05-30T18:12:40Z")

</div>

All,

I would like to test some secure pages that I’m developing in my  
WEBrick-based development environment.

I’ve done some research and it appears that I need to create a new  
command that will start a HTTPS based WEBrick server. Is this correct?

Also, it appears that the https.rb module is not included with the  
WEBrick bundled in Rails. So, I will need to go get that piece, right?

Lastly, do I need to set up a cert. of my own on the server side to test  
with?

Thanks,  
Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [May 30, 2006, 6:54pm UTC](https://www.ruby-forum.com/t/implementing-https-with-webrick/62003/2 "2006-05-30T18:54:54Z")

</div>

Wes G. wrote:

> All,
> 
> I would like to test some secure pages that I’m developing in my  
> WEBrick-based development environment.
> 
> I’ve done some research and it appears that I need to create a new  
> command that will start a HTTPS based WEBrick server. Is this correct?
> 
> Also, it appears that the https.rb module is not included with the  
> WEBrick bundled in Rails. So, I will need to go get that piece, right?
> 
> Lastly, do I need to set up a cert. of my own on the server side to test  
> with?
> 
> Thanks,  
> Wes

I found this:

[http://lists.rubyonrails.org/pipermail/rails/2006-January/012432.html](http://lists.rubyonrails.org/pipermail/rails/2006-January/012432.html)

and it appears to successfully start up a SSL Webrick for me.

I also found where all of the WEBrick stuff was stored in the standard  
library for 1.8.4.

But I’d like to understand more about how that script works.

1. What does OpenSSL::SSL::VERIFY\_NONE do?
2. I assume that the ::SSLCertName tells WEBrick to cause a SSL cert. to  
be generated? Is that correct?

Thanks,  
Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [May 30, 2006, 7:16pm UTC](https://www.ruby-forum.com/t/implementing-https-with-webrick/62003/3 "2006-05-30T19:16:57Z")

</div>

Wes G. wrote:

> Wes G. wrote:
> 
> > All,
> > 
> > I would like to test some secure pages that I’m developing in my  
> > WEBrick-based development environment.
> > 
> > I’ve done some research and it appears that I need to create a new  
> > command that will start a HTTPS based WEBrick server. Is this correct?
> > 
> > Also, it appears that the https.rb module is not included with the  
> > WEBrick bundled in Rails. So, I will need to go get that piece, right?
> > 
> > Lastly, do I need to set up a cert. of my own on the server side to test  
> > with?
> > 
> > Thanks,  
> > Wes
> 
> I found this:
> 
> [http://lists.rubyonrails.org/pipermail/rails/2006-January/012432.html](http://lists.rubyonrails.org/pipermail/rails/2006-January/012432.html)
> 
> and it appears to successfully start up a SSL Webrick for me.
> 
> I also found where all of the WEBrick stuff was stored in the standard  
> library for 1.8.4.
> 
> But I’d like to understand more about how that script works.
> 
> 1. What does OpenSSL::SSL::VERIFY\_NONE do?
> 2. I assume that the ::SSLCertName tells WEBrick to cause a SSL cert. to  
> be generated? Is that correct?
> 
> Thanks,  
> Wes

I am successfully running my SSL server, however, I am unable to use  
redirect\_to to do my redirects to a different port? How does one use  
url\_for to generate a URL for a specific port?

Thanks,  
Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [May 30, 2006, 7:27pm UTC](https://www.ruby-forum.com/t/implementing-https-with-webrick/62003/4 "2006-05-30T19:27:42Z")

</div>

Craig W. wrote:

> On Tue, 2006-05-30 at 19:16 +0200, Wes G. wrote:
> 
> > > > Also, it appears that the https.rb module is not included with the  
> > > > [http://lists.rubyonrails.org/pipermail/rails/2006-January/012432.html](http://lists.rubyonrails.org/pipermail/rails/2006-January/012432.html)  
> > > > be generated? Is that correct?
> > > 
> > > Thanks,  
> > > Wes
> > 
> > I am successfully running my SSL server, however, I am unable to use  
> > redirect\_to to do my redirects to a different port? How does one use  
> > url\_for to generate a URL for a specific port?
> 
> * * *
> 
> generally, you would use url:port#  
> i.e.  
> [https://www.domain.com:81](https://www.domain.com:81)
> 
> Craig

I’d like to do something like this:

redirect\_to :protocol =\> ‘https://’, :action =\> ‘login\_form’

but be able to specify the port.

I tried using :host =\> request.host + ‘:3001’ but it didn’t work.

Do I specify additional params to url\_for or do I just set up a route to  
always build an https URL with a port of 3001?

Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [May 30, 2006, 7:24pm UTC](https://www.ruby-forum.com/t/implementing-https-with-webrick/62003/5 "2006-05-30T19:24:15Z")

</div>

On Tue, 2006-05-30 at 19:16 +0200, Wes G. wrote:

> > > Also, it appears that the https.rb module is not included with the  
> > > [http://lists.rubyonrails.org/pipermail/rails/2006-January/012432.html](http://lists.rubyonrails.org/pipermail/rails/2006-January/012432.html)  
> > > be generated? Is that correct?
> > 
> > Thanks,  
> > Wes
> 
> I am successfully running my SSL server, however, I am unable to use  
> redirect\_to to do my redirects to a different port? How does one use  
> url\_for to generate a URL for a specific port?

* * *

generally, you would use url:port#  
i.e.  
[https://www.domain.com:81](https://www.domain.com:81)

Craig

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [May 30, 2006, 7:34pm UTC](https://www.ruby-forum.com/t/implementing-https-with-webrick/62003/6 "2006-05-30T19:34:05Z")

</div>

Wes G. wrote:

> Craig W. wrote:
> 
> > On Tue, 2006-05-30 at 19:16 +0200, Wes G. wrote:
> > 
> > > > > Also, it appears that the https.rb module is not included with the  
> > > > > [http://lists.rubyonrails.org/pipermail/rails/2006-January/012432.html](http://lists.rubyonrails.org/pipermail/rails/2006-January/012432.html)  
> > > > > be generated? Is that correct?
> > > > 
> > > > Thanks,  
> > > > Wes
> > > 
> > > I am successfully running my SSL server, however, I am unable to use  
> > > redirect\_to to do my redirects to a different port? How does one use  
> > > url\_for to generate a URL for a specific port?
> > 
> > * * *
> > 
> > generally, you would use url:port#  
> > i.e.  
> > [https://www.domain.com:81](https://www.domain.com:81)
> > 
> > Craig
> 
> I’d like to do something like this:
> 
> redirect\_to :protocol =\> ‘https://’, :action =\> ‘login\_form’
> 
> but be able to specify the port.
> 
> I tried using :host =\> request.host + ‘:3001’ but it didn’t work.
> 
> Do I specify additional params to url\_for or do I just set up a route to  
> always build an https URL with a port of 3001?
> 
> Wes

A cursory reading of the URL rewriting code shows that if you want to  
override the port, then you must do it as part of the host, using  
something like

url\_for :host =\> request.host + ‘:####’ where #### is the name of the  
new port.

Wes
