我在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版本:
$ 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 zstdopenssl:
$ openssl version
OpenSSL 1.1.1l 24 Aug 2021curl能够启动TLSv1.2连接,当我运行curl --tlsv1.2 https://bolmaster2.com时,我确实得到了网站。
有谁有主意吗?在这上面工作了1.5天,不知道还能做什么
发布于 2021-10-06 16:08:45
在这里,curl似乎不是问题所在,因为它似乎可以工作,至少在ruby之外使用时是这样。您尝试连接到的API是什么?也就是说,xxx.myapi.xxx在你的ruby代码中的真正价值是什么?我怀疑是HTTP端点只支持TLSv1.0...还是使用客户机库指定(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_codehttps://stackoverflow.com/questions/69067894
复制相似问题