首页 \ 问答 \ Mechanize和HTTParty中的“主机名与服务器证书不匹配”错误(“Hostname does not match the server certificate” error in Mechanize and HTTParty)

Mechanize和HTTParty中的“主机名与服务器证书不匹配”错误(“Hostname does not match the server certificate” error in Mechanize and HTTParty)

在Occationally,当我访问HTTPartyMechanize的网站时,我收到此错误:

hostname "www.example.com" does not match the server certificate

我可以看到如果你使用open方法有一个解决方法,但我不知道如何利用上面的宝石。

Mechanize的Stacktrace:

agent = Mechanize.new
agent.read_timeout              = 180
agent.open_timeout              = 180
agent.user_agent_alias          = 'Mac Safari'
agent.redirect_ok               = :all
agent.follow_meta_refresh       = :anywhere
agent.follow_meta_refresh_self  = true
agent.get("https://some-domain.com")
/home/me/.rbenv/versions/2.2.2/lib/ruby/2.2.0/openssl/ssl.rb:232:in `post_connection_check'
/home/me/.rbenv/versions/2.2.2/lib/ruby/2.2.0/net/http.rb:925:in `connect'
/home/me/.rbenv/versions/2.2.2/lib/ruby/2.2.0/net/http.rb:863:in `do_start'
/home/me/.rbenv/versions/2.2.2/lib/ruby/2.2.0/net/http.rb:858:in `start'
/home/me/applications/myapp/shared/bundle/ruby/2.2.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:700:in `start'
/home/me/applications/myapp/shared/bundle/ruby/2.2.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:965:in `reset'
/home/me/applications/myapp/shared/bundle/ruby/2.2.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:628:in `connection_for'
/home/me/applications/myapp/shared/bundle/ruby/2.2.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:994:in `request'
/home/me/applications/myapp/shared/bundle/ruby/2.2.0/gems/mechanize-2.7.4/lib/mechanize/http/agent.rb:267:in `fetch'
/home/me/applications/myapp/shared/bundle/ruby/2.2.0/gems/mechanize-2.7.4/lib/mechanize.rb:464:in `get'

HTTParty的HTTParty

HTTParty.get("https://some-domain.com")
/home/me/.rbenv/versions/2.2.2/lib/ruby/2.2.0/openssl/ssl.rb:232:in `post_connection_check'
/home/me/.rbenv/versions/2.2.2/lib/ruby/2.2.0/net/http.rb:925:in `connect'
/home/me/.rbenv/versions/2.2.2/lib/ruby/2.2.0/net/http.rb:863:in `do_start'
/home/me/.rbenv/versions/2.2.2/lib/ruby/2.2.0/net/http.rb:852:in `start'
/home/me/.rbenv/versions/2.2.2/lib/ruby/2.2.0/net/http.rb:1375:in `request'
/home/me/applications/myapp/shared/bundle/ruby/2.2.0/gems/httparty-0.13.7/lib/httparty/request.rb:117:in `perform'
/home/me/applications/myapp/shared/bundle/ruby/2.2.0/gems/httparty-0.13.7/lib/httparty.rb:545:in `perform_request'
/home/me/applications/myapp/shared/bundle/ruby/2.2.0/gems/httparty-0.13.7/lib/httparty.rb:476:in `get'

Occationally, when I visit a website with HTTParty or Mechanize, I get this error:

hostname "www.example.com" does not match the server certificate

I can see that there is a workaround if you use the open method, but I'm not sure how to leverage that the above gems.

Stacktrace for Mechanize:

agent = Mechanize.new
agent.read_timeout              = 180
agent.open_timeout              = 180
agent.user_agent_alias          = 'Mac Safari'
agent.redirect_ok               = :all
agent.follow_meta_refresh       = :anywhere
agent.follow_meta_refresh_self  = true
agent.get("https://some-domain.com")
/home/me/.rbenv/versions/2.2.2/lib/ruby/2.2.0/openssl/ssl.rb:232:in `post_connection_check'
/home/me/.rbenv/versions/2.2.2/lib/ruby/2.2.0/net/http.rb:925:in `connect'
/home/me/.rbenv/versions/2.2.2/lib/ruby/2.2.0/net/http.rb:863:in `do_start'
/home/me/.rbenv/versions/2.2.2/lib/ruby/2.2.0/net/http.rb:858:in `start'
/home/me/applications/myapp/shared/bundle/ruby/2.2.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:700:in `start'
/home/me/applications/myapp/shared/bundle/ruby/2.2.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:965:in `reset'
/home/me/applications/myapp/shared/bundle/ruby/2.2.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:628:in `connection_for'
/home/me/applications/myapp/shared/bundle/ruby/2.2.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:994:in `request'
/home/me/applications/myapp/shared/bundle/ruby/2.2.0/gems/mechanize-2.7.4/lib/mechanize/http/agent.rb:267:in `fetch'
/home/me/applications/myapp/shared/bundle/ruby/2.2.0/gems/mechanize-2.7.4/lib/mechanize.rb:464:in `get'

Stacktrace for HTTParty:

HTTParty.get("https://some-domain.com")
/home/me/.rbenv/versions/2.2.2/lib/ruby/2.2.0/openssl/ssl.rb:232:in `post_connection_check'
/home/me/.rbenv/versions/2.2.2/lib/ruby/2.2.0/net/http.rb:925:in `connect'
/home/me/.rbenv/versions/2.2.2/lib/ruby/2.2.0/net/http.rb:863:in `do_start'
/home/me/.rbenv/versions/2.2.2/lib/ruby/2.2.0/net/http.rb:852:in `start'
/home/me/.rbenv/versions/2.2.2/lib/ruby/2.2.0/net/http.rb:1375:in `request'
/home/me/applications/myapp/shared/bundle/ruby/2.2.0/gems/httparty-0.13.7/lib/httparty/request.rb:117:in `perform'
/home/me/applications/myapp/shared/bundle/ruby/2.2.0/gems/httparty-0.13.7/lib/httparty.rb:545:in `perform_request'
/home/me/applications/myapp/shared/bundle/ruby/2.2.0/gems/httparty-0.13.7/lib/httparty.rb:476:in `get'

原文:https://stackoverflow.com/questions/38094990
更新时间:2022-10-30 18:10

最满意答案

我按照这里的说明设法解决了这个问题 。 在我使用Emacs的内置python.el之前,我使用过python-mode.el,但根据emacswiki ,“Emacs 22中的版本有一堆问题”。 希望在Windows XP上运行Emacs 22的其他人有一天发现这个有用!


I managed to work it out, following the instructions here. I used python-mode.el, when before I had been using Emacs' built-in python.el, but according to emacswiki, "The version in Emacs 22 has a bunch of problems". Hope someone else running Emacs 22 on Windows XP finds this useful one day!

相关问答

更多
  • 如果您使用的是GNU Emacs 21或之前的版本,或者XEmacs,请使用python-mode.el。 GNU Emacs 22 python.el将无法工作。 在GNU Emacs 22上,python.el可以工作,并且与GNU Emacs自己的符号解析和完成,ElDoc等更好地结合。我自己使用XEmacs,所以我不使用它,并且我听到人们抱怨说它没有过去的工作非常好,但有更新可以解决一些问题(例如,在您链接的emacswiki页面上),并且您希望现在有些内容可以集成到上游。 如果我是GNU Emac ...
  • 在Windows中,它不会轻松工作,而且非常烦人。 首先,确保已安装pyreadline。 接下来,我使用了一个bat文件,它位于我的系统路径中,包含: [ipython.bat] @python.exe -i C:\devel\Python\2.7-bin\Scripts\ipython.py --pylab %* 接下来获取python-mode.el并删除ipython.el。 后者已弃用,python-mode包含其功能。 相应地更改ipython.py文件的路径并保存。 现在,在您的Emacs ...
  • 我使用EmacsW32 ,它的效果很好。 编辑:我现在使用常规的GNU Emacs 24,见下文。 有关详细信息,请参阅其EmacsWiki页面 。 对我来说,最大的优点是: 它有一个版本的emacsclient启动Emacs服务器,如果没有服务器正在运行(打开所有的文件在同一个Emacs窗口) 它包括几个有用的包,如Nxml 它有一个Windows安装程序,或者你可以从源代码构建它 关于XEmacs,根据Steve Yegge的这篇文章 : 总而言之,我认为XEmacs的市场份额要低得多,性能更差,更多的 ...
  • 你的路径中有一个空间。 用双引号括起来。 例如: python.exe "C:\Python Scripts\Primefactorization.py" Your path has a space in it. Enclose it in double quotes. For example: python.exe "C:\Python Scripts\Primefactorization.py"
  • python.el highlihghts左侧的任务以不同的颜色。 众所周知,它不适用于复杂的[1]。 但看起来你展示的例子很简单(例如第537行的xfast_image )。 如果您有Python代码片段来重现该问题,发送错误报告将有助于Emacs开发人员[2]。 [1] https://github.com/fgallina/python.el/issues/32 [2] https://github.com/fgallina/python.el#bug-reports python.el highli ...
  • 有没有一种方法只显示结果? elpy已经有一个自定义变量: (setq elpy-shell-echo-input nil) 每次执行脚本后,如何在右侧设置缓冲区,只显示当前结果,即清除之前执行的结果? 谢谢。 elpy没有这个功能。 但是你可以创建一个包装函数并将其绑定到相同的键上: (define-key elpy-mode-map (kbd "C-c C-c") (lambda (p) (interactive "P") (ignore-errors (with-cu ...
  • 您可以编写两个块:一个仅由解释器解析,另一个仅由Emacs解析: #!/usr/bin/python # coding: us-ascii print "Hello World" # Local Variables: # mode: python # coding: us-ascii-unix # End: 注意(1)us-ascii是Python 2.x中的默认值; (2)Emacs通常能够自动确定行结束约定; 所以你可以在不宣布任何事情的情况下相处。 You can write two b ...
  • 我认为这不是Python 3的问题。 IMO,Python 3是对Python 2的大改进。此外,从官方来源 : Python 2.x是遗留的,Python 3.x是该语言的现在和未来。 我认为问题在于git。 让我详细说明一下。 Python(请参阅PEP 397 )和git(请参阅git钩子 )都带来了UNIX #! 用于将脚本启动到ms-windows的在线机制。 Python实现只是试图确定你想要的Python版本,并启动它。 AFAICT,git版本( 最近建立在msys上 )只是试图执行命令。 ...
  • set-default-font真的很旧,而且在Emacs 23中已经弃用了它的新名字set-frame-font(这并不是太好)。 目前的Emacs手册提出了几种设置默认字体的方法 ,但我假设你已经找到了这些,看到你已经尝试过set-default-font ... 我使用的elisp代码实际上与所提出的所有方法不同: ;; [in .emacs] ;; Use 10-pt Consolas as default font (set-face-attribute 'default nil ...
  • 我按照这里的说明设法解决了这个问题 。 在我使用Emacs的内置python.el之前,我使用过python-mode.el,但根据emacswiki ,“Emacs 22中的版本有一堆问题”。 希望在Windows XP上运行Emacs 22的其他人有一天发现这个有用! I managed to work it out, following the instructions here. I used python-mode.el, when before I had been using Emacs' b ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)