php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39236 Error in function openssl_get_privatekey
Submitted: 2006-10-23 13:07 UTC Modified: 2006-10-24 09:56 UTC
From: kprzemek at coig dot katowice dot pl Assigned: pajoye (profile)
Status: Not a bug Package: OpenSSL related
PHP Version: 5.1.6 OS: RHEL4
Private report: No CVE-ID: None
 [2006-10-23 13:07 UTC] kprzemek at coig dot katowice dot pl
Description:
------------
Private key password is always Ok, no matter if the password is right or wrong. And it's not OK, because if I give wrong private key password, I should get an error. So I guess this function isn't working well. Everything is OK on php4.4.2 Is is because php5? I had the same error. No matter if the password is right or wrong it's OK (it's functioning) and it shouldnt't be.

Reproduce code:
---------------
public function userPassCheck($password,$nruser,$name) {
      $nras=(int)$this->asID;
      ifx_textasvarchar(1);
      $sql="SELECT priv_key".
           "  FROM user_ssl ".
           " WHERE nras=$nras ".
           "   AND nruser=$nruser";
      $rs=$this->db->Execute($sql);
      if (!$rs) {
         $this->blad="<b>Error...</b><br>".
         $this->db->ErrorNo()." - ".
         $this->db->ErrorMsg();
         throw new Exception($this->blad);
      }
      $this->privkey=$rs->fields['priv_key'];
  $rsCert=openssl_get_privatekey($this->privkey,$password);
      if($rsCert) {
         echo "<br>OK";
      } else {
         echo "<br>NOT OK";
      }
   }

Expected result:
----------------
If password is wrong I expect "NOT OK" if is right "OK".

Actual result:
--------------
Always "OK".

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-23 13:18 UTC] pajoye@php.net
Please provide an example without external data, a link to a (sample) private key and the password to use.
 [2006-10-24 08:42 UTC] kprzemek at coig dot katowice dot pl
Sorry my mistake. I use the private key wthout password. I don't know haw I could not notice that. Thanks for help. Everything in openssl_get_privatekey works fine.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 12:01:31 2024 UTC