Windows 上的另一个 openssl 问题 VERIFY_NONE 没有帮助

发布于 2024-10-28 04:49:14 字数 2555 浏览 0 评论 0原文

我正在尝试制作一个小 ruby​​ 脚本来上传我自己的视频,这是完整的代码,它非常短:

    require 'openssl'
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE # warning: already initialized constant VERIFY_PEER \n 0 
    require 'youtube_it'
    require 'rest-client'

    # Authentication
    auth_devkey      = '...'
    auth_user        = '...'
    auth_pass        = '...'

    # Getting auth token
    response    = RestClient.post "https://www.google.com/accounts/ClientLogin", {:Email => auth_user, :Passwd => auth_pass, :service => "youtube", :source => "..."}, :content_type => 'application/x-www-form-urlencoded'
    auth_token  = response[/(?<=auth=).*/i]
    # so far so good

    # creating a new youtube_it client
    yt_client   = YouTubeIt::Client.new(:username => auth_user, :password =>  auth_pass, :dev_key => auth_devkey)
    # A-Okay


    # Uploading video
    vpath       = "c:/downloads/videos/video.mov"
    upload_response = yt_client.video_upload(File.open(vpath), :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test], :list => 'denied')

    # big error here
    OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
            from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:677:in `connect'
            from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:677:in `connect'
            from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:637:in `do_start'
            from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:626:in `start'
            from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:1160:in `request'
            from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rest-client-1.6.1/lib/restclient/net_http_ext.rb:17:in `request'
            from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:970:in `post'
            from C:/Ruby192/lib/ruby/gems/1.9.1/gems/youtube_it-1.4.1/lib/youtube_it/request/video_upload.rb:525:in `auth_token'
            from C:/Ruby192/lib/ruby/gems/1.9.1/gems/youtube_it-1.4.1/lib/youtube_it/request/video_upload.rb:463:in `authorization_hea
    ders'
            from C:/Ruby192/lib/ruby/gems/1.9.1/gems/youtube_it-1.4.1/lib/youtube_it/request/video_upload.rb:94:in `upload'
            from C:/Ruby192/lib/ruby/gems/1.9.1/gems/youtube_it-1.4.1/lib/youtube_it/client.rb:99:in `video_upload'
            from (irb):81
            from C:/Ruby192/bin/irb:12:in `<main>'

我确信我是否可以立即提供任何其他信息,我可能会错过在这里粘贴,这是解决这个问题所必需的。我不想在没有谷歌搜索至少 4 小时的情况下轻易问问题,但我找不到任何有用的东西。

感谢十亿!

I am trying to make a little ruby script to upload my own video And here's the complete code, it's pretty short:

    require 'openssl'
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE # warning: already initialized constant VERIFY_PEER \n 0 
    require 'youtube_it'
    require 'rest-client'

    # Authentication
    auth_devkey      = '...'
    auth_user        = '...'
    auth_pass        = '...'

    # Getting auth token
    response    = RestClient.post "https://www.google.com/accounts/ClientLogin", {:Email => auth_user, :Passwd => auth_pass, :service => "youtube", :source => "..."}, :content_type => 'application/x-www-form-urlencoded'
    auth_token  = response[/(?<=auth=).*/i]
    # so far so good

    # creating a new youtube_it client
    yt_client   = YouTubeIt::Client.new(:username => auth_user, :password =>  auth_pass, :dev_key => auth_devkey)
    # A-Okay


    # Uploading video
    vpath       = "c:/downloads/videos/video.mov"
    upload_response = yt_client.video_upload(File.open(vpath), :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test], :list => 'denied')

    # big error here
    OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
            from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:677:in `connect'
            from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:677:in `connect'
            from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:637:in `do_start'
            from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:626:in `start'
            from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:1160:in `request'
            from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rest-client-1.6.1/lib/restclient/net_http_ext.rb:17:in `request'
            from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:970:in `post'
            from C:/Ruby192/lib/ruby/gems/1.9.1/gems/youtube_it-1.4.1/lib/youtube_it/request/video_upload.rb:525:in `auth_token'
            from C:/Ruby192/lib/ruby/gems/1.9.1/gems/youtube_it-1.4.1/lib/youtube_it/request/video_upload.rb:463:in `authorization_hea
    ders'
            from C:/Ruby192/lib/ruby/gems/1.9.1/gems/youtube_it-1.4.1/lib/youtube_it/request/video_upload.rb:94:in `upload'
            from C:/Ruby192/lib/ruby/gems/1.9.1/gems/youtube_it-1.4.1/lib/youtube_it/client.rb:99:in `video_upload'
            from (irb):81
            from C:/Ruby192/bin/irb:12:in `<main>'

I am sure if I can immediately supply any other information and I might miss pasting here and that is needed to solve this. I don't want to ask questions here lightly without googling at least 4 hours,but I can't find anything helpful.

Thanks a billion!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

§普罗旺斯的薰衣草 2024-11-04 04:49:14

大家好,这个错误已在 youtube_it 的最新版本中修复,您可以在此处查看

https://github。 com/kylejginavan/youtube_it/commit/032f2800ae4c4ab9f6000b23150e3a8d3517815f

问候!

hi guys this errors was fixed in the last version of youtube_it, you can see here

https://github.com/kylejginavan/youtube_it/commit/032f2800ae4c4ab9f6000b23150e3a8d3517815f

regards!

牵你的手,一向走下去 2024-11-04 04:49:14

问题是你不能这样做:

   OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE 

你必须修改 SSLContext 实例的 :verify_mode 属性。
您可以尝试通过rest-client内的instance_variable_get获取NET::HTTP对象的实例变量,然后相应地设置:verify_mode。

更好的方法是直接设置rest-client本身的 :verify_ssl 属性:

RestClient::Request.execute(:method => :post, :url => 'http://example.com', :verify_ssl => OpenSSL::SSL::VERIFY_NONE )

为了进一步阅读,我建议查看源代码 此处

the problem is that you cannot do this:

   OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE 

you have to modify the :verify_mode attribute of the SSLContext instance.
you can try to get the instance variable of the NET::HTTP object via instance_variable_get inside the rest-client and then set the :verify_mode accordingly.

the better way is to directly set the :verify_ssl attribute of the rest-client itself:

RestClient::Request.execute(:method => :post, :url => 'http://example.com', :verify_ssl => OpenSSL::SSL::VERIFY_NONE )

for further reading i suggest to look at the source code here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文