没有可用于包“pecl.php.net/imagick”的发布。OpenSSL 错误?

huangapple go评论77阅读模式
英文:

No releases available for package "pecl.php.net/imagick". OpenSSL Error?

问题

我道歉如果这是一个重复问题,但已经发布的问题的答案都没有帮到我。

最近,我们的 php5.6-apache 的 Dockerfile 不再能够成功构建了。失败的地方是在通过 pecl 安装 imagick 时。

# 启用 imagick
RUN apt-get update && apt-get install -y libmagickwand-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
RUN yes '' | pecl install -vvv imagick-beta

运行这行代码会因为以下错误而失败:

> [12/25] RUN yes '' | pecl -vvv install imagick-beta:
#0 1.354 
#0 1.354 Warning: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages:
#0 1.354 error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in PEAR/Proxy.php on line 183
#0 1.355 
#0 1.355 Warning: fsockopen(): Failed to enable crypto in PEAR/Proxy.php on line 183
#0 1.357 
#0 1.357 Warning: fsockopen(): unable to connect to ssl://pecl.php.net:443 (Unknown error) in PEAR/Proxy.php on line 183
#0 1.359 No releases available for package "pecl.php.net/imagick"
#0 1.360 Cannot initialize 'channel://pecl.php.net/imagick-beta', invalid or missing package file
#0 1.362 Package "channel://pecl.php.net/imagick-beta" is not valid
#0 1.366 install failed
------
failed to solve: process "/bin/sh -c yes '' | pecl -vvv install imagick-beta" did not complete successfully: exit code: 1

我找到的唯一一个最近的帖子是关于有人遇到相同问题的 错误报告,但我不确定我在哪里可以看到有关修复此错误的更新。在错误报告中,最后一个人说:

证书到期日期设置为昨天。我在考虑全球范围内当前所有失败的 Docker 构建流水线 <3

他是指 php.net 的 SSL 证书吗?因为我检查了一下,它看起来是有效的,所以我不明白为什么它无法连接。

PEAR/proxy.php 的第 183 行是:

$fp = @fsockopen($host, $port, $errno, $errstr);

所以如果我理解正确,Docker 容器无法通过 pecl.php.net:443 建立正确的连接?有人遇到过相同的问题吗?

提前感谢任何(建设性的)答案!

英文:

I apologise if this is a duplicate, but none of the already posted question's answers helped me.

Recently, the Dockerfile for our php5.6-apache doesn't want to build anymore. The line where it fails is when imagick is trying to be installed via pecl.

# Enable imagick
RUN apt-get update &amp;&amp; apt-get install -y libmagickwand-dev --no-install-recommends &amp;&amp; rm -rf /var/lib/apt/lists/*
RUN yes &#39;&#39; | pecl install -vvv imagick-beta

Running this line fails due to the following error:

 &gt; [12/25] RUN yes &#39;&#39; | pecl -vvv install imagick-beta:
#0 1.354 
#0 1.354 Warning: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages:
#0 1.354 error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in PEAR/Proxy.php on line 183
#0 1.355 
#0 1.355 Warning: fsockopen(): Failed to enable crypto in PEAR/Proxy.php on line 183
#0 1.357 
#0 1.357 Warning: fsockopen(): unable to connect to ssl://pecl.php.net:443 (Unknown error) in PEAR/Proxy.php on line 183
#0 1.359 No releases available for package &quot;pecl.php.net/imagick&quot;
#0 1.360 Cannot initialize &#39;channel://pecl.php.net/imagick-beta&#39;, invalid or missing package file
#0 1.362 Package &quot;channel://pecl.php.net/imagick-beta&quot; is not valid
#0 1.366 install failed
------
failed to solve: process &quot;/bin/sh -c yes &#39;&#39; | pecl -vvv install imagick-beta&quot; did not complete successfully: exit code: 1

The only recent post I found about someone having the same issue is this bug report but I'm not sure about the channel where I'd see any updates on fixing this bug. In the bug report the last person states the following:

> Certificate expiry is set to yesterday. I'm thinking about all docker build pipelines currently failing all over the world <3

Does he mean about php.net's SSL certificate? Because when I checked it it looks valid so I don't understand why it can not connect.

line 183 of PEAR/proxy.php is the following:

$fp = @fsockopen($host, $port, $errno, $errstr);

So if I understand correctly, the docker container can not establish a proper connection via pecl.php.net:443? Has anyone encountered the same issue?

Thanks in advance for any (constructive) answers!

答案1

得分: 2

这是最终解决了所有问题的修复:

FROM php:alpine AS cacert

FROM php:7.0-fpm-alpine # 实际使用的容器镜像

COPY --from=cacert /etc/ssl /root/ssl

RUN mv /etc/ssl/openssl.cnf* /root/ssl && rm -rf /etc/ssl && mv /root/ssl /etc/ssl \
  && pear update-channels \
  && pear upgrade

据我了解,在旧版本的 PHP 镜像中,CA 证书已过期,需要用更新的证书替换。这可能是一个小技巧,但它将帮助您在旧版本镜像的 CA 证书得到更新之前顺利进行。

英文:

This is the fix that finally got everything working:

FROM php:alpine AS cacert

FROM php:7.0-fpm-alpine # Image that the container is actually using

COPY --from=cacert /etc/ssl /root/ssl

RUN mv /etc/ssl/openssl.cnf* /root/ssl &amp;&amp; rm -rf /etc/ssl &amp;&amp; mv /root/ssl /etc/ssl \
  &amp;&amp; pear update-channels \
  &amp;&amp; pear upgrade

From what I understand the CA cert is expired in older versions of PHP images and need to be replaced with a newer one. This might be a bit of hack but it will get you through until the older images' CA certs will be updated.

答案2

得分: 1

根据我看到的情况,这表明SSL证书验证失败,要修复它,您可以尝试在Dockerfile中禁用SSL证书验证,方法是在pecl安装命令之前添加以下行!

RUN pecl config-set "disable-tls" "yes"

或者您也可以更新pecl.php.netSSL证书。

祝好运!

英文:

As I see it indicates that the SSL certificate verification failed, to fix it you can try disabling SSL certificate verification in the Dockerfile by adding this line before the pecl install command!

RUN pecl config-set &quot;disable-tls&quot; &quot;yes&quot;

or you can also updating the SSL certificate for pecl.php.net

good luck!

答案3

得分: 1

我能够通过直接从项目的git存储库中安装软件包来解决这个问题。

FROM php:7.0-alpine

RUN apk update && apk add --no-cache imagemagick-dev libtool make g++

RUN wget https://github.com/ImageMagick/ImageMagick6/archive/refs/tags/6.9.12-28.tar.gz && \
     tar -xzf 6.9.12-28.tar.gz && \
     cd ImageMagick6-6.9.12-28 && \
     ./configure && \
     make && \
     make install

RUN wget https://pecl.php.net/get/imagick-3.4.4.tgz && \
     tar -xzf imagick-3.4.4.tgz && \
     cd imagick-3.4.4 && \
     phpize && \
     ./configure --with-imagick=/usr/local && \
     make && \
     make install

RUN echo "extension=imagick.so" > /usr/local/etc/php/conf.d/imagick.ini
英文:

I was able to get around this problem by installing the packages directly from the project's git repository.

FROM php:7.0-alpine

RUN apk update &amp;&amp; apk add --no-cache imagemagick-dev libtool make g++

RUN wget https://github.com/ImageMagick/ImageMagick6/archive/refs/tags/6.9.12-28.tar.gz &amp;&amp; \
     tar -xzf 6.9.12-28.tar.gz &amp;&amp; \
     cd ImageMagick6-6.9.12-28 &amp;&amp; \
     ./configure &amp;&amp; \
     make &amp;&amp; \
     make install

RUN wget https://pecl.php.net/get/imagick-3.4.4.tgz &amp;&amp; \
     tar -xzf imagick-3.4.4.tgz &amp;&amp; \
     cd imagick-3.4.4 &amp;&amp; \
     phpize &amp;&amp; \
     ./configure --with-imagick=/usr/local &amp;&amp; \
     make &amp;&amp; \
     make install

RUN echo &quot;extension=imagick.so&quot; &gt; /usr/local/etc/php/conf.d/imagick.ini

huangapple
  • 本文由 发表于 2023年6月22日 19:10:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76531289.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定