php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28671 wrong serialNumber (-1) using openssl_x509_parse
Submitted: 2004-06-07 14:35 UTC Modified: 2006-10-21 00:36 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: jgrillon at capgemini dot fr Assigned: pajoye (profile)
Status: Closed Package: OpenSSL related
PHP Version: 4.3.7 OS: Linux 2.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jgrillon at capgemini dot fr
New email:
PHP Version: OS:

 

 [2004-06-07 14:35 UTC] jgrillon at capgemini dot fr
Description:
------------
I'm always getting "-1" as serialNumber for my certificate.

I can't see why the serial number is stored into a long in openssl.c :
add_assoc_long(return_value, "serialNumber",            ASN1_INTEGER_get(X509_get_serialNumber(cert)));

I guess the serial number is too big for a long...
Can't we store it as string ?
add_assoc_asn1_string(return_value, "serialNumberAsString",             X509_get_serialNumber(cert));

Thanks.

Here is the certificate I used :
-----BEGIN CERTIFICATE-----
MIIC3DCCAkWgAwIBAgIQeqhtj1pzHCrTTq2AldV0ejANBgkqhkiG9w0BAQQFADAy
MRcwFQYDVQQKEw5FLUFDSEFUIE1JTkRFRjEXMBUGA1UEAxMORS1BQ0hBVCBNSU5E
RUYwHhcNMDQwMTA1MDAwMDAwWhcNMDYwMTA0MjM1OTU5WjCB5DEOMAwGA1UEBxQF
UEFSSVMxCzAJBgNVBAYTAkZSMRcwFQYDVQQKFA5FLUFDSEFUIE1JTkRFRjEtMCsG
A1UECxQkRW50LiAtIENhcCBHZW1pbmkgRXJuc3QgWW91bmcgRnJhbmNlMR8wHQYD
VQQLFBZTSVJFTiAtIDMyODc4MTc4NjAwMDUzMTQwMgYDVQQDEytDR0VZIEZyYW5j
ZSAtIENhcCBHZW1pbmkgRXJuc3QgWW91bmcgRnJhbmNlMSYwJAYJKoZIhvcNAQkB
FhdkZ2FlbWEtbWNvQGNhcGdlbWluaS5mcjCBnzANBgkqhkiG9w0BAQEFAAOBjQAw
gYkCgYEApFgcuVTuUe0z+iGTaPw7yVxhZsPq6aIqGHsCvU9fqUcymbmg9l4oTfAk
gR5bvDo+JTQb1/OPlQCKqyVa7wn6lPs97dMOZMobjCRcvw7z0jVphortA1NS8FRH
6LsWELZ13uC57IIakpW726Vz3tST9qHHbQoWbX/n8NjHcwL4zUECAwEAAaNAMD4w
CQYDVR0TBAIwADALBgNVHQ8EBAMCBaAwEQYJYIZIAYb4QgEBBAQDAgeAMBEGCmCG
SAGG+EUBBgkEAwEB/zANBgkqhkiG9w0BAQQFAAOBgQAWdmEu8TkFdgqA/xN6llo9
zZR3EUH0X5HstxJRYgofcQyfumJHhgvaNB8vkDhZ3iJORVVxcJ27W36TAJ6b4jcr
yWjO/nc42XdgknS8r9NIV7VKzmjY7Ip2+9N6JOAWFkjGrnF1G69nrerIJavJTzrb
PYlQnzJO6SHAoi5j6WsKPw==
-----END CERTIFICATE-----


Reproduce code:
---------------
 $fp = fopen("xxx.cer", "r");
 $cert = fread($fp, 8192);
 $r = @openssl_x509_read($cert);
 print_r(openssl_x509_parse($r));

Expected result:
----------------
Something like

[...]
 [serialNumber] => 7a a8 6d 8f 5a 73 1c 2a d3 4e ad 80 95 d5 74 7a
[...]


Actual result:
--------------
[...]
 [serialNumber] => -1
[...]

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-08 09:51 UTC] derick@php.net
Assigning to the maintainer, wez.
 [2005-05-17 12:20 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-05-25 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2006-10-21 00:36 UTC] pajoye@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

It has been a long time, but better later than never (also no feedback does not help to catch such bugs).

Fixed in HEAD, will MFH for 5.2.1.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Nov 24 13:01:23 2020 UTC