I'm using Mechanize to scrape a site and am getting errors related to a hostname mismatch. I've discovered that the root of the issue is SNI being used on the site I'm scraping and I'd like to specify the hostname to ensure the correct certificate is being used.
Here's my current setup:
agent = Mechanize.new
agent.user_agent = custom_user_agent
agent.verify_mode = OpenSSL::SSL::VERIFY_PEER
page = agent.get "website.com"
And here's what I think I need to add (or something along these lines) to ensure the correct cert is used:
OpenSSL::SSL::SSLSocket.hostname = "website.com"
Is this possible to do in Mechanize, or do I need to figure out how to manually specify the cert to use?
For context, I'm aware of the VERIFY_NONE
solution but would prefer to avoid it given the vulnerabilities it introduces.