Gist/snippet for Ruby OpenSSL::SSL::VERIFY_NONE alternative?

I’ve found HTTPS (The S being OpenSSL) in Ruby to be very troublesome. One thing is the certificate issues they have had. Another is a bad performance problem with OpenSSL under Windows. Under Windows OpenSSL use some extremely slow debug Win32 API functions. They added a time out to work around this - but for some reason there are different code paths for different compilers. And the one used to compile the libs we use in SketchUp didn’t have the time out in the inner most loop - which meant that on a fresh SketchUp start, using OpenSSL for the first time it would spend 3-5secs on generating random seed. That’s best case scenario. If there is a large model loaded this can yield minutes.

We’ve tried some very kludgy workarounds, but they are not something I trust to be reliable. My current recommendation is to build a Ruby C/C++ extension and use C/C++ libs to do the HTTPS communication - without OpenSSL.
We have a sample for Ruby C/C++ extensions on GitHub:

Another argument for going this route is if you want to do these HTTP(S) requests in the background. Ruby threads are now native since Ruby 2.0 - but Ruby still manages the threads so they are not 100% like you’d expect. There is also an issue with Ruby threads inside of SketchUp where they won’t run unless the main thread is busy doing something (UI interaction - or a zero-delay-timer, which is just another kludge…).

Doing a Ruby extension might seem like extra ordeal, but the number of compound issues with HTTPS, OpenSSL and Ruby Threads actually makes it the saner option.