首页
\
问答
\
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,当我访问
HTTParty
或Mechanize
的网站时,我收到此错误: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
orMechanize
, 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(Emacs and Python)[2022-02-24]
如果您使用的是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 ...
-
Windows中的Emacs(Emacs in Windows)[2022-10-30]
我使用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 ...
-
Python,Emacs和编码(Python, Emacs and Encoding)[2023-01-21]
您可以编写两个块:一个仅由解释器解析,另一个仅由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 ...