【问题标题】:ruby does not use TLS1.0ruby 不使用 TLS1.0
【发布时间】:2021-11-03 03:37:47
【问题描述】:

我正在使用 macOS Big Sur 11.5.2,并且正在运行 ruby​​ 服务器。我现在在尝试连接到 api 时遇到 SSL 连接错误。我相信这是因为无论出于何种原因,ruby 都使用 TLSv1.0 握手而不是 v1.2 或 v1.3。

在连接期间,我正在记录发生的事情并得到以下信息:

Calling API: MyApi.get_something ...
  Trying [IP_ADDRESS]...
Connected to xxx.myapi.xxx ([IP_ADDRESS]) port 443 (#1)
Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
TLSv1.0 (OUT), TLS handshake, Client hello (1):
qa5N?+?k
?#Έ0??e?5{Q?5\nߗ;?985
???32/?.*(%xxx.myapi.xxxUnknown SSL protocol error in connection to xxx.myapi.xxx:443 
Closing connection 1
ETHON: performed EASY effective_url=https://xxx.myapi.xxx response_code=0 return_code=ssl_connect_error total_time=0.096385
HTTP response body ~BEGIN~

~END~

Exception when calling MyApi->get_something: SSL connect error
HTTP status code: 0
Completed 500 Internal Server Error in 240ms (ActiveRecord: 100.9ms)

我多次卸载 curl 和 openssl 并重建 rvm,但没有成功。

卷曲版本:

$ curl --version
curl 7.78.0 (x86_64-apple-darwin20.4.0) libcurl/7.78.0 (SecureTransport) OpenSSL/1.1.1l zlib/1.2.11 brotli/1.0.9 zstd/1.5.0 libidn2/2.3.2 libssh2/1.9.0 nghttp2/1.44.0 librtmp/2.3 OpenLDAP/2.5.7
Release-Date: 2021-07-21
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL TLS-SRP UnixSockets zstd

openssl:

$ openssl version
OpenSSL 1.1.1l  24 Aug 2021

curl 能够启动 TLSv1.2 连接,当我运行 curl --tlsv1.2 https://bolmaster2.com 时,我确实获得了网站。

任何人的想法?工作了1.5天,不知道还能做什么

【问题讨论】:

  • 你能告诉我们你的代码吗?你在你的代码中尝试了什么来让它工作?

标签: ruby curl openssl tls1.2


【解决方案1】:

curl 似乎不是这里的问题,因为它似乎可以工作,至少在 ruby​​ 之外使用时是这样。您要连接到什么 API?即,您的 ruby​​ 代码中 xxx.myapi.xxx 的真正价值是什么?我怀疑是仅支持 TLSv1.0 的 HTTP 端点...或者您是否使用客户端库(ethon?)指定仅使用 TLSv1.0?

这段 ruby​​ 代码的输出是什么?

require "ethon"
# Checks which curl version ethon lib uses...
puts Ethon::Curl.version
easy = Ethon::Easy.new(url: "https://bolmaster2.com")
easy.perform
puts easy.response_code

【讨论】:

    猜你喜欢
    • 2022-07-25
    • 2017-12-11
    • 1970-01-01
    • 1970-01-01
    • 2017-04-13
    • 2019-11-03
    • 1970-01-01
    • 2010-09-27
    • 2022-06-29
    相关资源
    最近更新 更多