<legend id='YSF79'><style id='YSF79'><dir id='YSF79'><q id='YSF79'></q></dir></style></legend>

  • <small id='YSF79'></small><noframes id='YSF79'>

      • <bdo id='YSF79'></bdo><ul id='YSF79'></ul>

        <i id='YSF79'><tr id='YSF79'><dt id='YSF79'><q id='YSF79'><span id='YSF79'><b id='YSF79'><form id='YSF79'><ins id='YSF79'></ins><ul id='YSF79'></ul><sub id='YSF79'></sub></form><legend id='YSF79'></legend><bdo id='YSF79'><pre id='YSF79'><center id='YSF79'></center></pre></bdo></b><th id='YSF79'></th></span></q></dt></tr></i><div id='YSF79'><tfoot id='YSF79'></tfoot><dl id='YSF79'><fieldset id='YSF79'></fieldset></dl></div>

      1. <tfoot id='YSF79'></tfoot>

        PHP 上的 OpenSSL 问题 - 不同版本的不同行为

        时间:2023-10-15
          <i id='0gmDf'><tr id='0gmDf'><dt id='0gmDf'><q id='0gmDf'><span id='0gmDf'><b id='0gmDf'><form id='0gmDf'><ins id='0gmDf'></ins><ul id='0gmDf'></ul><sub id='0gmDf'></sub></form><legend id='0gmDf'></legend><bdo id='0gmDf'><pre id='0gmDf'><center id='0gmDf'></center></pre></bdo></b><th id='0gmDf'></th></span></q></dt></tr></i><div id='0gmDf'><tfoot id='0gmDf'></tfoot><dl id='0gmDf'><fieldset id='0gmDf'></fieldset></dl></div>
            <bdo id='0gmDf'></bdo><ul id='0gmDf'></ul>
              <tbody id='0gmDf'></tbody>

                <legend id='0gmDf'><style id='0gmDf'><dir id='0gmDf'><q id='0gmDf'></q></dir></style></legend>
              1. <tfoot id='0gmDf'></tfoot>

                <small id='0gmDf'></small><noframes id='0gmDf'>

                • 本文介绍了PHP 上的 OpenSSL 问题 - 不同版本的不同行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  (这个问题最初发布在 ServerFault 上 - 我已将其删除并移至此处.)

                  我有一台运行 PHP 5.3.5 的开发机器和一台运行 PHP 5.3.8 的生产机器.

                  I have a development machine running PHP 5.3.5 and a production machine running PHP 5.3.8.

                  以下代码在开发机器上运行:

                  The following code runs on the development machine:

                  <?php
                  $key = "-----BEGIN PUBLIC KEY-----
                  MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC0x+2RiQ+LCZNAUcl/Ecf1NrTr
                  lhjOiHaVC+w/y+UJevqVcDstD22OJGwT13B9T47OuQG9BmzcZQYLcShUMhVD/Owu
                  9+8PcK51EnBd0lym6+z/WixpnqfQonyKiqq5ytmYKUlUv39J8QQUI2geyvY9VpWS
                  wyNcFUs7wPl2zsLCPQIDAQAB
                  -----END PUBLIC KEY-----";
                  
                  $data = "Hello, world!";
                  
                  $key1 = openssl_get_publickey($key);
                  print_r ($key1);
                  echo "<p>";
                  
                  $res = openssl_public_encrypt($data, $encrypted_data, $key1, OPENSSL_PKCS1_PADDING);
                  
                  echo base64_encode($encrypted_data);
                  

                  在我的开发机器上,此代码输出一个资源和一个编码字符串.我会在这里复制它,但当然它每次都会改变.在生产机器上,此代码产生资源编号和以下 PHP 错误:

                  On my development machine, this code outputs a resource and an encoded string. I would copy it here, but of course it changes each time. On the production machine, this code produces the resource number and the following PHP errors:

                  PHP Warning:  openssl_public_encrypt(): Don't know how to get public key from this private key in C:xxx	est.php on line 15
                  PHP Warning:  openssl_public_encrypt(): key parameter is not a valid public key in C:xxx	est.php on line 15
                  

                  不幸的是,目前无法在生产机器上安装旧版本的 PHP,因为在其上运行的其他应用程序至少需要 5.3.8.

                  Unfortunately, installing an older version of PHP on the production machine is not an option at the moment because of other applications that are running on it which require 5.3.8 as a minimum.

                  如果我升级到 5.4.x 会有帮助吗?

                  Would it help if I upgraded to 5.4.x?

                  我知道 5.3.5 上的 OpenSSL 版本是 0.9.8,而 5.3.8 中的版本是 1.0.0.我想那里可能有问题.有什么办法可以解决这个问题吗?

                  I do know that the version of OpenSSL on 5.3.5 is 0.9.8 whereas the version in 5.3.8 is 1.0.0. I imagine that there might be a problem there. Is there any way to work around that?

                  我试图从 OpenSSL.org 站点和 PHP 错误跟踪器中尽可能多地找出答案,但我不知道我在寻找什么.

                  I have tried to find out as much as I can from the OpenSSL.org site, and the PHP bug tracker, but I don't know what I'm looking for.

                  问候,

                  菲利普

                  推荐答案

                  根据这篇文章,该问题与 XAMPP/Windows 安装中的 Apache 和 PHP 的不同 OpenSSL 版本有关.我对 openssl_verify 有类似的问题.我通过对 Apache 和 PHP 使用相同的 OpenSSL 版本(替换 DLL)解决了这个问题.这是解决方案链接.

                  According to this post, the issue is related to different OpenSSL versions of Apache and PHP in the XAMPP/Windows installation. I had a similar issue with openssl_verify. I solved it by using the same OpenSSL version for both Apache and PHP (replacing DLLs). Here's a link to the solution.

                  "我找到了问题的解决方案,在默认的 1.7.7 安装中,/apache/bin/中似乎有 2 个错误文件需要替换为/php/中存在的文件 (libeay32.ddl 和 ssleay32.dll)"

                  这篇关于PHP 上的 OpenSSL 问题 - 不同版本的不同行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:当看似不在 PHPMailer、TLS、Openssl、file_get_contents 中时,LetsEncrypt 下一篇:“libcrypto.so.1.0.0:未找到版本‘OPENSSL_1.0.1’"在 shell_exec 期

                  相关文章

                    <legend id='1Mhyf'><style id='1Mhyf'><dir id='1Mhyf'><q id='1Mhyf'></q></dir></style></legend>
                  1. <i id='1Mhyf'><tr id='1Mhyf'><dt id='1Mhyf'><q id='1Mhyf'><span id='1Mhyf'><b id='1Mhyf'><form id='1Mhyf'><ins id='1Mhyf'></ins><ul id='1Mhyf'></ul><sub id='1Mhyf'></sub></form><legend id='1Mhyf'></legend><bdo id='1Mhyf'><pre id='1Mhyf'><center id='1Mhyf'></center></pre></bdo></b><th id='1Mhyf'></th></span></q></dt></tr></i><div id='1Mhyf'><tfoot id='1Mhyf'></tfoot><dl id='1Mhyf'><fieldset id='1Mhyf'></fieldset></dl></div>
                    <tfoot id='1Mhyf'></tfoot>

                    <small id='1Mhyf'></small><noframes id='1Mhyf'>

                      <bdo id='1Mhyf'></bdo><ul id='1Mhyf'></ul>