SSL Error on HTTP POST (Unknown Protocol)

前端 未结 2 1545
谎友^
谎友^ 2021-02-10 02:40

Trying to connect to Imgur API via SSL gives me an error. Here\'s the code and the error:

  API_URI = URI.parse(\'https://api.imgur.com\')
  API_PUBLIC_KEY = \'C         


        
相关标签:
2条回答
  • 2021-02-10 03:07

    For me it was because I had started the server as a http (tcp://) servers instead of https (ssl://).

    i.e.

    bundle exec puma config.ru -b 'tcp://0.0.0.0:3456?key=/path/to/key.key&cert=/path/to/cert.crt'
    

    instead of:

    bundle exec puma config.ru -b 'ssl://0.0.0.0:3456?key=/path/to/key.key&cert=/path/to/cert.crt'
    
    0 讨论(0)
  • 2021-02-10 03:20

    Specifying the port when creating the HTTP client fixed this problem.

    http = Net::HTTP.new(API_URI.host, API_URI.port)
    

    or

    http = Net::HTTP.new(API_URI.host, 443)
    
    0 讨论(0)
提交回复
热议问题