rubyonjets / jets

Ruby on Jets
http://rubyonjets.com
MIT License
2.6k stars 181 forks source link

OpenSSL error when doing a POST with HTTParty #495

Closed AlexGascon closed 4 years ago

AlexGascon commented 4 years ago

Checklist

My Environment

Software Version
Operating System Ubuntu 18.10
Jets 1.9.30
Ruby 2.5

Expected Behaviour

Making an HTTP request succeeds

Current Behavior

Making an HTTP request results in an SSL error

Step-by-step reproduction instructions

I'm encountering an SSL error when trying to make an HTTP request from the Lambda function. This is the traceback of the error in Lambda

{
  "errorMessage": "SSL_connect returned=1 errno=0 state=error: certificate verify failed (certificate has expired)",
  "errorType": "Function<OpenSSL::SSL::SSLError>",
  "stackTrace": [
    "/var/lang/lib/ruby/2.5.0/net/protocol.rb:44:in `connect_nonblock'",
    "/var/lang/lib/ruby/2.5.0/net/protocol.rb:44:in `ssl_socket_connect'",
    "/var/lang/lib/ruby/2.5.0/net/http.rb:985:in `connect'",
    "/var/lang/lib/ruby/2.5.0/net/http.rb:920:in `do_start'",
    "/var/lang/lib/ruby/2.5.0/net/http.rb:909:in `start'",
    "/var/lang/lib/ruby/2.5.0/net/http.rb:1458:in `request'",
    "/opt/ruby/gems/2.5.0/gems/httparty-0.17.3/lib/httparty/request.rb:145:in `perform'",
    "/opt/ruby/gems/2.5.0/gems/httparty-0.17.3/lib/httparty.rb:594:in `perform_request'",
    "/opt/ruby/gems/2.5.0/gems/httparty-0.17.3/lib/httparty.rb:524:in `post'",
    "/opt/ruby/gems/2.5.0/gems/httparty-0.17.3/lib/httparty.rb:631:in `post'",
<My code here>

Unfortunately, I haven't been able to reproduce it on my local environment: the same code works perfectly fine on it, which discards an actual issue with the server certificate as the error indicates.

There are a few issues that make this problem strange:

I know that with this information it's very difficult to pinpoint the root cause, but the fact that it's completely impossible to reproduce on my local environment leads me to believe that the issue has to be either on the gems that are uploaded to the Lambda or on the Lambda itself, so I wanted to ask in case you have any lead that may at least help clarify the situation. In case it's helpful, these are the links to my Gemfile and my Gemfile.lock

Let me know if there's any other information that I can provide to help debug the issue. Thanks in advance!

AlexGascon commented 4 years ago

Finally I contacted AWS Support and they confirmed that the error is on the Lambda environment, sorry for the trouble!