Docker Ruby SSL_connect returned=1 errno=0 state=error: wrong signature type

Docker Ruby SSL_connect returned=1 errno=0 state=error: wrong signature type

我在 Docker 容器中安装了 ruby 2.7 运行使用 Faraday 构建了一个相当简单的 HTTP 客户端:

conn = Faraday.new("https://jinio.com.ph")
conn.post("/tracker", {p: @code}.to_json, {"Content-Type" => "application/json"})

此代码 returns 容器内的 SSL 错误 "wrong signature type"。

Faraday::SSLError (SSL_connect returned=1 errno=0 state=error: wrong signature type)

关于如何解决这个问题有什么想法吗?仅供参考,如果我 运行 这个 Mac OS,代码 运行s 没有错误

我的Docker文件如果有帮助的话:

FROM ruby:2.7
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client nano
RUN mkdir /app
WORKDIR /app
COPY Gemfile /app/Gemfile
COPY Gemfile.lock /app/Gemfile.lock
RUN bundle install
COPY . /app

# Script to be executed every time the container starts.
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000

# Start server
CMD ["rails", "server", "-b", "0.0.0.0"]

我遇到了同样的问题,通过更改 Dockerfile 解决了。

FROM ruby:2.7之后添加

RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/' /etc/ssl/openssl.cnf

原始资料来源(日文):

https://qiita.com/masayuki14/items/c34eafb9d6130e2c5b67

接受的解决方案无法立即使用,因为我需要使用 OpenSSL 1.1.1f 31 Mar 2020Ubuntu 20.04.3 LTS 上解决该问题。 我在 https://askubuntu.com/a/1233456/306766 找到的解决方案对我有用。

You need to add this to the beginning of your config file (/etc/ssl/openssl.cnf):

openssl_conf = default_conf

And then this to the end:

[ default_conf ]

ssl_conf = ssl_sect

[ssl_sect]

system_default = system_default_sect

[system_default_sect] MinProtocol = TLSv1.2 CipherString =
DEFAULT:@SECLEVEL=1