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

        <bdo id='T0RZC'></bdo><ul id='T0RZC'></ul>

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

        openssl_verify 和“错误:0906D06C:PEM 例程:PEM_read_bio:无起始行"

        openssl_verify and quot;error:0906D06C:PEM routines:PEM_read_bio:no start linequot;(openssl_verify 和“错误:0906D06C:PEM 例程:PEM_read_bio:无起始行)

            • <small id='9c6nX'></small><noframes id='9c6nX'>

                <bdo id='9c6nX'></bdo><ul id='9c6nX'></ul>
              • <i id='9c6nX'><tr id='9c6nX'><dt id='9c6nX'><q id='9c6nX'><span id='9c6nX'><b id='9c6nX'><form id='9c6nX'><ins id='9c6nX'></ins><ul id='9c6nX'></ul><sub id='9c6nX'></sub></form><legend id='9c6nX'></legend><bdo id='9c6nX'><pre id='9c6nX'><center id='9c6nX'></center></pre></bdo></b><th id='9c6nX'></th></span></q></dt></tr></i><div id='9c6nX'><tfoot id='9c6nX'></tfoot><dl id='9c6nX'><fieldset id='9c6nX'></fieldset></dl></div>
                  <tbody id='9c6nX'></tbody>
                  <legend id='9c6nX'><style id='9c6nX'><dir id='9c6nX'><q id='9c6nX'></q></dir></style></legend>
                  <tfoot id='9c6nX'></tfoot>
                  本文介绍了openssl_verify 和“错误:0906D06C:PEM 例程:PEM_read_bio:无起始行"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试在 PHP 中使用 OpenSSL 函数进行 RSA 签名/验证.当我尝试使用我的公钥执行 openssl_verify 时,出现此错误:error:0906D06C:PEMroutines:PEM_read_bio:no start line,但函数本身可以正常工作(如果消息被修改则返回 0,如果完好则返回 1).openssl_sign 工作正常.

                  I am trying to use OpenSSL function for RSA sign/verify in PHP. When I try to do openssl_verify using my public key, I am getting this error: error:0906D06C:PEM routines:PEM_read_bio:no start line, but the function itself works correctly (returns 0 if messages was modified, and 1 if intact). openssl_sign works fine.

                  我该如何解决?

                  目前,我使用的是由 openssl 生成的公钥:

                  Currently, I use public key generated by openssl:

                  define("SC_MSG_PUBLIC", <<<EOD
                  -----BEGIN PUBLIC KEY-----
                  MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALjPcOckMHDVLiUstcRwwx8kF5PzsiEs
                  rskyndWisbXMLU9BHomXwL7Qg2L91jE+sNSobkzBDF41CbwDiNlofZUCAwEAAQ==
                  -----END PUBLIC KEY-----
                  EOD
                  );
                  

                  知道为什么会触发此错误,但一切正常吗?

                  Any ideas why this error triggers, but things works fine?

                  尝试从私有中生成公钥并使用它,但它似乎完全相同,相同的错误消息:-S

                  Tried to generate public key out of private, and use it, but it appeared to be exactly the same, same error message :-S

                  $pkey = openssl_pkey_get_private(SC_MSG_PRIVATE);
                  $keyDetails = openssl_pkey_get_details($pkey);
                  file_put_contents('c:publickey', $keyDetails['key']);
                  

                  此外,我尝试安装所有更新版本(PHP 5.3.1、OpenSSL 1.0.0a) - 结果相同.而且,我在窗户上.

                  Also, I've tried to install newer versions of everything (PHP 5.3.1, OpenSSL 1.0.0a) - same result. And, I am on windows.

                  推荐答案

                  您是否尝试使用包含您的公钥而不是纯公钥的(可能是自签名的)证书调用 openssl_verify()关键?

                  Have you tried to call openssl_verify() with a (maybe self-signed) certificate containing your public key instead of a pure public key ?

                  据我所知,一些 PHP OpenSSL 函数不能正确支持裸公钥,尽管尽管出现错误,但它确实验证正确似乎很奇怪.

                  As far as I know, some PHP OpenSSL functions do not properly support naked public keys although it seems strange that it does verify correctly in spite of the error.

                  <?php
                  $private = openssl_pkey_get_private(file_get_contents('private'), 'passphrase');
                  
                  // This causes the "no start line" error when using a naked public key:
                  $public  = openssl_pkey_get_public(file_get_contents('public')); // <-- this should be cert
                  
                  echo openssl_error_string()."
                  ";
                  
                  openssl_sign('Test', $sig, $private);
                  var_dump(openssl_verify('Test', $sig, $public));
                  
                  echo openssl_error_string()."
                  ";
                  ?>
                  

                  在 bash 等 Linux/UNIX shell 中将公钥转换为简单证书的示例(有关更多信息,请参阅 OpenSSL 文档或一些教程):

                  Example for converting a public key to a simple certificate in a Linux/UNIX shell such as bash (refer to the OpenSSL documentation or some tutorials for more):

                  # Create certificate request
                  openssl req -new -days 3600 -key [PRIVATE-KEY-FILE] -out [REQUEST-TMP-FILE]
                  
                  # Create certificate from request
                  RANDFILE=[RANDOM-TMP-FILE] openssl x509 -req -in [REQUEST-TMP-FILE] -signkey [PRIVATE-KEY-FILE] -out [CERTIFICATE-OUT-FILE]
                  

                  这也会创建您之后可能想要删除的临时文件,即 [REQUEST-TMP-FILE][RANDOM-TMP-FILE].

                  This will also create temporary files you might want to delete afterwards, namely [REQUEST-TMP-FILE] and [RANDOM-TMP-FILE].

                  PHP 示例代码可以在 http://de 找到.php.net/manual/en/function.openssl-csr-new.php.

                  PHP sample code can be found at http://de.php.net/manual/en/function.openssl-csr-new.php.

                  这篇关于openssl_verify 和“错误:0906D06C:PEM 例程:PEM_read_bio:无起始行"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Is Joomla 2.5 much faster than Joomla 1.5 Querywise(Joomla 2.5 比 Joomla 1.5 Querywise 快得多吗)
                  How to share Joomla login session from one joomla website to one ASP.Net MVC website(如何将 Joomla 登录会话从一个 joomla 网站共享到一个 ASP.Net MVC 网站)
                  htaccess redirect root to subdirectory but allow index.php in root AND query strings to function(htaccess 将根重定向到子目录,但允许根和查询字符串中的 index.php 起作用)
                  Joomla include database functions(Joomla 包含数据库功能)
                  nl2br() not working when displaying SQL results(显示 SQL 结果时 nl2br() 不起作用)
                  Joomla 2.5 JFactory::getSession(); seems to be caching in firefox(Joomla 2.5 JFactory::getSession();似乎在 Firefox 中缓存)
                1. <i id='NeZdY'><tr id='NeZdY'><dt id='NeZdY'><q id='NeZdY'><span id='NeZdY'><b id='NeZdY'><form id='NeZdY'><ins id='NeZdY'></ins><ul id='NeZdY'></ul><sub id='NeZdY'></sub></form><legend id='NeZdY'></legend><bdo id='NeZdY'><pre id='NeZdY'><center id='NeZdY'></center></pre></bdo></b><th id='NeZdY'></th></span></q></dt></tr></i><div id='NeZdY'><tfoot id='NeZdY'></tfoot><dl id='NeZdY'><fieldset id='NeZdY'></fieldset></dl></div>

                      <bdo id='NeZdY'></bdo><ul id='NeZdY'></ul>

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

                              <tbody id='NeZdY'></tbody>
                            <tfoot id='NeZdY'></tfoot>
                          1. <legend id='NeZdY'><style id='NeZdY'><dir id='NeZdY'><q id='NeZdY'></q></dir></style></legend>