2

I been using httparty to communicate with a API for my rails application The problem I'm having was when decided to run it on a different server. we kept getting this error:

SSL_connect returned=1 errno=0 state=unknown state: tlsv1 alert protocol version

its running fine with no errors with my current environment so I'm not sure what I'm missing to make it run on my other server

my code:

    require 'httparty'
    require 'pp'
    require 'openssl'

    def self.get_token

    include HTTParty

    base_uri = self.base_url
    base_uri = base_uri+'oauth/'+'token'
    response =  HTTParty.post(base_uri,verify:false,
                    :body =>{
                         :grant_type=>'password',
                         :client_id=>'3',
                         :client_secret=> 'eGSjPBZV70IsJwnyjNn7EYI6vci0bGrFbJkJNVof',
                         :password=>'Passw0rd!',
                         :username=>'myemail@gmail.com'
                },)
        token = response.parsed_response['access_token']


    return token
end `
  • Possible duplicate of [How do I make HTTParty ignore SSL?](https://stackoverflow.com/questions/20955177/how-do-i-make-httparty-ignore-ssl) – Deepak Mahakale May 31 '18 at 05:24
  • @Deepak , although the "ignore SSL method" will remove the warning message, it is indicated only for tests purposes, since it disables the certificates verification and thus it disables the authentication process of the parties. – Dalton Cézane May 31 '18 at 05:36

1 Answers1

2

You are getting an alert/warning, not an error. This is possible due to the fact that the TLS version you are using is not recommended because of security issues.

According to HTTParty documentation, you can change the TLS version with the following code:

ssl_version :SSLv3

Try this v3 version or v2 version and see if it removes the warning message.

Dalton Cézane
  • 3,672
  • 2
  • 35
  • 60
  • Tried it and its still giving me the same warning – BananaTiger May 31 '18 at 05:45
  • Make sure you have the latest version of OpenSSL. If it is not updated, please do and see if it solves. – Dalton Cézane May 31 '18 at 12:48
  • After checking it looks like my colleague was actually using vagrang box precise instead of xenial which is what im using. was able to make it run after install a xenial box on his machine ,but we still need to figure out what went wrong. – BananaTiger Jun 01 '18 at 03:12