igrigorik / em-http-request

Asynchronous HTTP Client (EventMachine + Ruby)
1.22k stars 222 forks source link

ssl_verify_peer': unable to verify the server certificate for "xxxxxxxx.xxx" (OpenSSL::SSL::SSLError) #353

Closed natandiasm closed 2 years ago

natandiasm commented 2 years ago

error:

ssl_verify_peer': unable to verify the server certificate for "xxxxxxxxxxx" (OpenSSL::SSL::SSLError) from /usr/local/lib/ruby/gems/3.0.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:195:in run_machine' from /usr/local/lib/ruby/gems/3.0.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:195:inrun'

code:

EventMachine.run do brasilApi = EventMachine::HttpRequest.new('https://brasilapi.com.br/api/cep/v2/#{cep_formatado}', ssl: {verify_peer: true}).get awesomeapi_cep = EventMachine::HttpRequest.new('https://cep.awesomeapi.com.br/json/#{cep_formatado}', ssl: {verify_peer: true}).get cepaberto_cep = EventMachine::HttpRequest.new('https://www.cepaberto.com/api/v3/cep?cep=#{cep_formatado}', ssl: {verify_peer: true}).get

  brasilApi.callback { puts "brasil-api > #{brasilApi.response}" }
  awesomeapi_cep.callback { puts "awesomeapi > #{awesomeapi_cep.response}" }
  cepaberto_cep.callback { puts "cepaberto_cep > #{cepaberto_cep.response}" }
end

not working

natandiasm commented 2 years ago

Resolve: ssl: {verify_peer: false}