# Webrick, ssl and non-ssl on the same port

**URL:** <https://www.ruby-forum.com/t/webrick-ssl-and-non-ssl-on-the-same-port/64622>\
**Category:** Ruby\
**Created:** [August 15, 2006, 2:09pm UTC](https://www.ruby-forum.com/t/webrick-ssl-and-non-ssl-on-the-same-port/64622 "2006-08-15T14:09:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elgato](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@elgato](https://www.ruby-forum.com/u/elgato)\
**Post date:** [August 15, 2006, 2:09pm UTC](https://www.ruby-forum.com/t/webrick-ssl-and-non-ssl-on-the-same-port/64622/1 "2006-08-15T14:09:46Z")

</div>

Hello all,

I have sslized webrick server, but I’d like to have some parts of server  
accessible even without ssl. I’ve tried to search web and groups, but  
I haven’t found anything — any suggestions, how to get ssl and nonssl  
servlets on the same port?

Thanks in advance,

P.

---

<div class="post-metadata">

**Author:** ![elgato](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@elgato](https://www.ruby-forum.com/u/elgato)\
**Post date:** [August 15, 2006, 2:14pm UTC](https://www.ruby-forum.com/t/webrick-ssl-and-non-ssl-on-the-same-port/64622/2 "2006-08-15T14:14:25Z")

</div>

On 10.08.2006 17:54, Pavel S. wrote:

> Hello all,
> 
> I have sslized webrick server, but I’d like to have some parts of server  
> accessible even without ssl. I’ve tried to search web and groups, but I  
> haven’t found anything — any suggestions, how to get ssl and nonssl  
> servlets on the same port?

You could search the web for SSL protocl. I believe after connection  
some message is sent in the clear to indicate SSL is to be used. You  
could evaluate that and go on from there.

However, I don’t think it’s worth the effort. Note that HTTPS and HTTP  
use different ports by default anyway. It’s certainly far easier to  
open port 443 on the FW.

Kind regards

```
robert
```

---

<div class="post-metadata">

**Author:** ![elgato](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@elgato](https://www.ruby-forum.com/u/elgato)\
**Post date:** [August 15, 2006, 2:14pm UTC](https://www.ruby-forum.com/t/webrick-ssl-and-non-ssl-on-the-same-port/64622/3 "2006-08-15T14:14:46Z")

</div>

On 8/10/06, Pavel S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

what I think you’re proposing is not usually done for web sites. Do  
you want to open a server port and have it automatically detect an  
SSL/TLS client-hello so you can do an SSL handshake if present, and  
simply serve the connection with no encryption otherwise? If you do  
that, then how do you ensure that people will use encryption on the  
sensitive pages? It’s a lot of additional logic to make that happen.  
Just use two ports.

---

<div class="post-metadata">

**Author:** ![elgato](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@elgato](https://www.ruby-forum.com/u/elgato)\
**Post date:** [August 15, 2006, 7:54pm UTC](https://www.ruby-forum.com/t/webrick-ssl-and-non-ssl-on-the-same-port/64622/4 "2006-08-15T19:54:14Z")

</div>

On 8/10/06, Francis C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > P.
> 
> what I think you’re proposing is not usually done for web sites. Do  
> you want to open a server port and have it automatically detect an  
> SSL/TLS client-hello so you can do an SSL handshake if present, and  
> simply serve the connection with no encryption otherwise? If you do  
> that, then how do you ensure that people will use encryption on the  
> sensitive pages? It’s a lot of additional logic to make that happen.  
> Just use two ports.

The page is either available through http or https - these are two  
different URLs. So the request should get to the right type of  
service.

Of course it is simpler to use two ports (and it is the default  
anyway, you would have to use a port number with either http or https  
to get them use the same port). But it is an interesting idea  
nontheless.

Thanks

Michal
