Question

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!

Was it helpful?

Solution

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!

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top