php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #47728 openssl_pkcs7_sign ignores new openssl flags
Submitted: 2009-03-20 10:06 UTC Modified: 2025-08-11 17:49 UTC
From: josef dot andrysek at icewarp dot com Assigned: bukka (profile)
Status: Closed Package: OpenSSL related
PHP Version: 5.2.9 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: josef dot andrysek at icewarp dot com
New email:
PHP Version: OS:

 

 [2009-03-20 10:06 UTC] josef dot andrysek at icewarp dot com
Description:
------------
openssl_pkcs7_sign supports several new flags:
e.g. PKCS7_CRLFEOL,PKCS7_NOSMIMECAP...

1. openssl extension should define these constants
2. openssl extension should check the PKCS7_CRLFEOL and use appropriate line delimiter in call to BIO_printf()



Reproduce code:
---------------
look at ext\openssl\openssl.c



Expected result:
----------------
1) also new constants should be registered here
REGISTER_LONG_CONSTANT("PKCS7_NOSMIMECAP", PKCS7_NOSMIMECAP, CONST_CS|CONST_PERSISTENT);
	REGISTER_LONG_CONSTANT("PKCS7_NOOLDMIMETYPE", PKCS7_NOOLDMIMETYPE, CONST_CS|CONST_PERSISTENT);
	REGISTER_LONG_CONSTANT("PKCS7_CRLFEOL", PKCS7_CRLFEOL, CONST_CS|CONST_PERSISTENT);
	REGISTER_LONG_CONSTANT("PKCS7_STREAM", PKCS7_STREAM, CONST_CS|CONST_PERSISTENT);
	REGISTER_LONG_CONSTANT("PKCS7_NOCRL", PKCS7_NOCRL, CONST_CS|CONST_PERSISTENT);

2) newline symbol should depend on PKCS7_CRLFEOL flag
   (this style of coding is taken from openssl project itself)
	if (flags & PKCS7_CRLFEOL)
		mime_eol = "\r\n";
	else
		mime_eol = "\n"; 


if (strindex) {
				BIO_printf(outfile, "%s: %s%s", strindex, Z_STRVAL_PP(hval),mime_eol);
			} else {
				BIO_printf(outfile, "%s%s", Z_STRVAL_PP(hval),mime_eol);
			}


Actual result:
--------------
look at ext\openssl\openssl.c


1)
Line 701:
/* flags for S/MIME */
-  only old flags are defined here	


2)
if (strindex) {
				BIO_printf(outfile, "%s: %s\n", strindex, Z_STRVAL_PP(hval));
			} else {
				BIO_printf(outfile, "%s\n", Z_STRVAL_PP(hval));
			}


Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-20 11:23 UTC] pajoye@php.net
Right, and need one a couple of small changes+tests as well.
 [2010-12-20 14:26 UTC] jani@php.net
-Package: Feature/Change Request +Package: OpenSSL related
 [2017-10-24 07:33 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: pajoye +Assigned To:
 [2024-01-19 00:39 UTC] info at gomarketes dot exchange
The following pull request has been associated:

Patch Name: Extract functions to classes
On GitHub:  https://github.com/php/web-master/pull/12
Patch:      https://github.com/php/web-master/pull/12.patch
 [2025-08-11 17:36 UTC] bukka@php.net
The following pull request has been associated:

Patch Name: Fix #80495: Add PKCS7_CRLFEOL and PKCS7_NO_DUAL_CONTENT constants
On GitHub:  https://github.com/php/php-src/pull/19450
Patch:      https://github.com/php/php-src/pull/19450.patch
 [2025-08-11 17:49 UTC] bukka@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: bukka
 [2025-08-11 17:49 UTC] bukka@php.net
Apology for very long delay.

I added PKCS7_NOSMIMECAP, PKCS7_CRLFEOL, PKCS7_NOCRL and PKCS7_NO_DUAL_CONTENT that might be potentially useful in some cases.

The PKCS7_STREAM, PKCS7_PARTIAL and PKCS7_REUSE_DIGEST are flow specific and they don't make much sense and would require some other changes which are probably not worth it.


The PKCS7_NOOLDMIMETYPE was already added but I checked it anyway and it doesn't really do anything. It was added in 0.9.7 and the check for the old mime type removed in 1.0.0 so it's a bit pointless one
 [2025-08-11 18:47 UTC] git@php.net
Automatic comment on behalf of bukka
Revision: https://github.com/php/php-src/commit/10834d1572de41a04a7ab75ef2151d8c9e34c194
Log: Fix #47728: Add missing openssl constants
 [2025-08-11 18:47 UTC] git@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Aug 31 01:00:03 2025 UTC