TL;DR
This post is solution how to handle error “Hostname Does Not Match The Server Certificate” in Ruby.
Problem
Every SSL certificate has, among other information, signed site domain name. If that domain name does not match actual domain in browser address bar, you will get following error:
hostname "domain name" does not match the server certificate (OpenSSL::SSL::SSLError).
You will get various errors when certificate is not valid. Expired certificate is usual one. If you created self signed certificate for test site, you will get error that certificate root is not valid.
If this is production site, you should leave it immediately. But if this is test site, you want to handle such errors.
Solution
If you use Ruby gem httpclient, with following code you can handle this error:
http_client = HTTPClient.new { self.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE }