'Ruby 2.7 and TLS 1.3 with RestClient not working
I'm having problems trying to request an endpoint that is using TLS 1.3
require 'base64'
require 'openssl'
require 'rest-client'
auth_payload = {
grant_type: 'client_credentials',
scope: 'cobrancas.boletos-info cobrancas.boletos-requisicao'
}
encoded_token = Base64.strict_encode64(
'MY_CLIENT_ID:MY_CLIENT_SECRET'
)
response = RestClient::Request.execute(
method: 'post',
url: "https://oauth.sandbox.bb.com.br/oauth/token",
payload: auth_payload,
verify_ssl: OpenSSL::SSL::VERIFY_NONE,
headers: {
content_type: 'application/x-www-form-urlencoded',
authorization: "Basic #{encoded_token}"
}
)
I tried removing verify_ssl
and adding ssl_version: 'TLSv1_3'
and it returned the error unknown SSL method TLSv1_3 (ArgumentError)
Passing the verify_ssl: OpenSSL::SSL::VERIFY_NONE
attribute sometimes works and sometimes returns the error Connection reset by peer - SSL_connect (Errno::ECONNRESET)
Without passing the verify_ssl
and ssl_version
attributes returns the error SSL_connect returned=1 errno=0 peeraddr=1.1.1.1:443 state=error: certificate verify failed (unable to get local issuer certificate) (OpenSSL::SSL::SSLError)
Tried using Ruby 2.7.6 and 3.1.2 both don't work.
Through CURL it worked every time I tried (and there were many)
curl -X POST https://oauth.sandbox.bb.com.br/oauth/token -v \
-H "Authorization: Basic ${MY_TOKEN}" \
-d "grant_type=client_credentials"
I did a lot of research on the internet, as I understand it, Ruby still doesn't support https endpoints that use TLS 1.3, is that right?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|