# Turning off verify\_mode for SSL

**URL:** <https://www.ruby-forum.com/t/turning-off-verify-mode-for-ssl/92420>\
**Category:** Ruby\
**Created:** [April 19, 2007, 11:43am UTC](https://www.ruby-forum.com/t/turning-off-verify-mode-for-ssl/92420 "2007-04-19T11:43:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_MannI](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ac91a4/32.png) [@Robert\_MannI](https://www.ruby-forum.com/u/Robert_MannI)\
**Post date:** [April 19, 2007, 11:43am UTC](https://www.ruby-forum.com/t/turning-off-verify-mode-for-ssl/92420/1 "2007-04-19T11:43:47Z")

</div>

Hi!

In my rails tests, I get the warnings: warning: peer certificate won’t  
be  
verified in this SSL session

I found this on the ruby list:

Hi,

I’ve got a little Ruby script that needs to use SSL but doesn’t really  
worry about authentication at all. Here’s the relevant code:

```
  https = Net::HTTP.new(URL, 443)
  https.use_ssl = true
  data = ""
  https.start{|h|
    h.get2(url) {|resp|
      data = resp.body
    }
  }

```

When I run this, it works great but gives me (on STDERR):  
peer certificate won’t be verified in this SSL session

I don’t really care about the verification, so how should I turn this  
warning off or otherwise prevent it from printing?

Thanks,  
Keith

and the response:

K\> https = Net::HTTP.new(URL, 443)  
K\> https.use\_ssl = true

```
     https.verify_mode = OpenSSL::SSL::VERIFY_NONE

```

K\> data = “”  
K\> https.start{|h|  
K\> h.get2(url) {|resp|  
K\> data = resp.body  
K\> }  
K\> }

now my question: is it possible to turn https.verify\_mode =  
OpenSSL::SSL::VERIFY\_NONE on for all new Net::HTTP instances? I want to  
prevent getting that warning while I run my tests.

Thanks, Rob

---

<div class="post-metadata">

**Author:** ![Robert\_MannI](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ac91a4/32.png) [@Robert\_MannI](https://www.ruby-forum.com/u/Robert_MannI)\
**Post date:** [April 19, 2007, 1:15pm UTC](https://www.ruby-forum.com/t/turning-off-verify-mode-for-ssl/92420/2 "2007-04-19T13:15:46Z")

</div>

On Apr 19, 10:43 am, “Robert MannI” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> worry about authentication at all. Here’s the relevant code:  
> When I run this, it works great but gives me (on STDERR):  
> K\> https = Net::HTTP.new(URL, 443)
> 
> now my question: is it possible to turn https.verify\_mode =  
> OpenSSL::SSL::VERIFY\_NONE on for all new Net::HTTP instances? I want to  
> prevent getting that warning while I run my tests.
> 
> Thanks, Rob

Hi Rob,

I found this page via Google, [http://devmates.com/archive/48/](http://devmates.com/archive/48/)

HTH.

Regards,

Chris

> **[Ruby On The Shoulders Of Giants](https://rotsog.wordpress.com)**
>
> Code Red

---

<div class="post-metadata">

**Author:** ![Robert\_MannI](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ac91a4/32.png) [@Robert\_MannI](https://www.ruby-forum.com/u/Robert_MannI)\
**Post date:** [April 19, 2007, 1:41pm UTC](https://www.ruby-forum.com/t/turning-off-verify-mode-for-ssl/92420/3 "2007-04-19T13:41:17Z")

</div>

Hi Celldee,

thanks, but that just solves the problem if you already have a net/http  
instance var, in that case @http.

I need to solve this for all my Net::HTTP instances.

Best, Rob

---

<div class="post-metadata">

**Author:** ![Robert\_MannI](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ac91a4/32.png) [@Robert\_MannI](https://www.ruby-forum.com/u/Robert_MannI)\
**Post date:** [April 19, 2007, 3:44pm UTC](https://www.ruby-forum.com/t/turning-off-verify-mode-for-ssl/92420/4 "2007-04-19T15:44:56Z")

</div>

Robert MannI wrote:

> Hi Celldee,
> 
> thanks, but that just solves the problem if you already have a  
> net/http  
> instance var, in that case @http.
> 
> I need to solve this for all my Net::HTTP instances.
> 
> Best, Rob

Firstly:  
A: Because it makes it difficult to associate responses.  
Q: Why is top-quoting bad?

Secondly:  
Subclass Net::HTTP, and enhance the initialize method in your  
application?

–  
Phillip “CynicalRyan” Gawlowski  
[http://cynicalryan.110mb.com/](http://cynicalryan.110mb.com/)  
[http://clothred.rubyforge.org](http://clothred.rubyforge.org)

Rule of Open-Source Programming #20:

Open Code != Good Code
