ruby - SSL Error on HTTP POST (Unknown Protocol) -


trying connect imgur api via ssl gives me error. here's code , error:

  api_uri = uri.parse('https://api.imgur.com')   api_public_key = 'client-id --'    endpoints = {     :image   => '/3/image',     :gallery => '/3/gallery'   }    # public: upload image   #   # args    - image path image upload   #    def upload(image_path)     http = net::http.new(api_uri.host)     http.use_ssl = true     http.verify_mode = openssl::ssl::verify_none      params   = {'image' => file.open(image_path)}     request  = net::http::post.new(api_uri.request_uri)     request.set_form_data(params)     request.add_field('authorization', api_public_key)      response = http.request(request)     puts response.body   end 

and error:

`connect': ssl_connect returned=1 errno=0 state=sslv2/v3 read server hello a: unknown protocol (openssl::ssl::sslerror) 

i know verify_node not practice want test connection now.

ruby version: 1.9.2

specifying port when creating http client fixed problem.

http = net::http.new(api_uri.host, api_uri.port) 

or

http = net::http.new(api_uri.host, 443) 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -