<small id='11g48'></small><noframes id='11g48'>

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

      1. 使用 PHP 和 OpenSSL 将 P12 转换为 PEM

        Convert P12 to PEM using PHP and OpenSSL(使用 PHP 和 OpenSSL 将 P12 转换为 PEM)

          <bdo id='dYHMk'></bdo><ul id='dYHMk'></ul>
          <legend id='dYHMk'><style id='dYHMk'><dir id='dYHMk'><q id='dYHMk'></q></dir></style></legend>

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

              <tfoot id='dYHMk'></tfoot>

                  <small id='dYHMk'></small><noframes id='dYHMk'>

                    <tbody id='dYHMk'></tbody>

                • 本文介绍了使用 PHP 和 OpenSSL 将 P12 转换为 PEM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试将一些 .p12 文件转换为 .pem.

                  I'm trying to convert some .p12 files in to .pem.

                  在我的 mac 上它可以工作,没有交互,因为我将密码放入代码中,但是当我使用此代码时:

                  On my mac it works, with no interaction as i put the passwords in the code, but when i use this code:

                  system('openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12 -passin pass:');
                  system('openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12 -passout pass:1234 -passin pass:');
                  system('openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem -passin pass:1234');
                  system('cat apns-dev-cert.pem apns-dev-key-noenc.pem > apns-dev.pem');
                  

                  它会生成空白文件.

                  我的文件权限是 755.对于 passin,密码被设置为空,所以这就是为什么它们是空白的......这里没有 system() 的所有代码都在 mac 终端中工作..

                  My file permissions are 755. and for the passin the passwords were set to nothing so thats why they are blank... all the code here without the system() works in the mac terminal..

                  感谢阅读.希望能帮到你

                  thanks for reading. hope you can help

                  推荐答案

                  $filename = 'apns-dev-cert.p12';
                  $password = '...';
                  $results = array();
                  $worked = openssl_pkcs12_read(file_get_contents($filename), $results, $password));
                  if($worked) {
                      echo '<pre>', print_r($results, true), '</pre>';
                  } else {
                      echo openssl_error_string();
                  }
                  

                  请尝试运行此代码段.将 $password 设置为打开文件所需的任何密码.如果没有密码,请将其设置为空.我认为您的 openssl 命令不需要一个.

                  Please try running this snippet. Set $password to whatever passphrase is needed to open the file. If there's no password, set it to null. I don't believe one is needed from your openssl commands.

                  应该获得所需私钥的输出,可能在$results['pkey']中.

                  You should get output with the desired private key, probably inside $results['pkey'].

                  如果你在那里看到你的私钥,那么你可以把它传递给 openssl_pkey_export 以 PEM 格式获取它,然后您可以将其写入文件:

                  If you see your private key there, then you can pass it to openssl_pkey_export to get it in PEM format, which you can then write to a file:

                  $new_password = null;
                  $result = null;
                  $worked = openssl_pkey_export($results['pkey'], $result, $new_password);
                  if($worked) {
                      echo "<pre>It worked!  Your new pkey is:
                  ", $result, '</pre>';
                  } else {
                      echo openssl_error_string();
                  }
                  

                  如果需要,请将 $new_password 设置为所需的 pkey 密码.

                  Set $new_password to your desired pkey password, if you want one.

                  根据我在各种文档页面上阅读的内容,这 应该适合您.

                  This should work for you, based on what I'm reading on the various documentation pages.

                  如果您真的想继续使用 openssl 命令,请考虑使用 proc_open 而不是 system,以便您可以正确捕获错误消息.

                  If you really want to continue using the openssl command by shelling out, please consider using proc_open instead of system, so that you can properly catch error messages.

                  也有可能是 OpenSSL 正在尝试读取配置文件,并且没有读取权限,尽管它应该给您一个错误.

                  It's also possible that OpenSSL is trying to read the config file, and doesn't have permission to so, though it should give you an error about that.

                  这篇关于使用 PHP 和 OpenSSL 将 P12 转换为 PEM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

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

                      <small id='3Fc5q'></small><noframes id='3Fc5q'>

                          <tbody id='3Fc5q'></tbody>
                      • <tfoot id='3Fc5q'></tfoot>