Skip to content

Instantly share code, notes, and snippets.

/mech.rb Secret

Created September 1, 2016 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/ae720e3233faaf0d76cdbd7789883b0f to your computer and use it in GitHub Desktop.
Save anonymous/ae720e3233faaf0d76cdbd7789883b0f to your computer and use it in GitHub Desktop.
cert ||= OpenSSL::X509::Certificate.new File.read(certfile)
key ||= OpenSSL::PKey.read File.read(keyfile || certfile), pw
Mechanize.start {|a|
a.cert = cert
a.key = key
# root = OpenSSL::X509::Certificate.new File.read('/Users/bob/Internal Root CA 1.cer')
# mid = OpenSSL::X509::Certificate.new File.read('/Users/bob/Internal CA 1A.cer')
# a.cert_store = OpenSSL::X509::Store.new
# a.cert_store.add_cert root
# a.cert_store.add_cert mid
# OpenSSL::SSL.const_set(:VERIFY_PEER, OpenSSL::SSL::VERIFY_NONE)
# ::Object.const_set(:I_KNOW_THAT_OPENSSL_VERIFY_PEER_EQUALS_VERIFY_NONE_IS_WRONG, nil)
a.verify_mode = OpenSSL::SSL::VERIFY_NONE
a.get("https://#{URI(url).host}:8271/api/1.0/getVersion")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment