Skip to content

Conversation

DASPRiD
Copy link
Contributor

@DASPRiD DASPRiD commented Oct 20, 2018

This PR introduces a wrapper around OpenSSL's X509_verify() function.

The tests all work, but since I'm not neither confident in OpenSSL nor C at all, I'd like to have someone verify that all I've done is correct before anyone merges this.

@php-pulls
Copy link

Comment on behalf of petk at php.net:

Labelling. Thank you for the pull request @DASPRiD

@php-pulls
Copy link

Comment on behalf of petk at php.net:

Labelling

@DASPRiD
Copy link
Contributor Author

DASPRiD commented Oct 20, 2018

By the way, I take that it's probably too late for this to make it into 7.3, correct?

}
key = php_openssl_evp_from_zval(zkey, 1, NULL, 0, 0, &keyresource);
if (key == NULL) {
RETURN_FALSE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case probably leaks cert.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would I have to do RETVAL_FALSE; instead? As I said, I'm not too confident with this stuff :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you are missing a X509_free(cert); here


if (err < 0) {
php_openssl_store_errors();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: indent

@nikic
Copy link
Member

nikic commented Oct 20, 2018

/cc @bukka for review

}
cert = php_openssl_x509_from_zval(zcert, 0, NULL);
if (cert == NULL) {
RETURN_FALSE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems a bit strange to return false if the return type is int. If you want to follow X509_verify, then it should probably return -1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I think openssl_verify() does it similar.

@bukka
Copy link
Member

bukka commented Oct 21, 2018

I think it seems reasonable once all the comments are addressed.

@DASPRiD
Copy link
Contributor Author

DASPRiD commented Oct 22, 2018

@bukka @nikic Should all be addressed :)

@DASPRiD
Copy link
Contributor Author

DASPRiD commented Nov 14, 2018

@petk What's blocking the merge? :)

@petk
Copy link
Member

petk commented Nov 14, 2018

Sorry for the delay. Seems like tests have passed and issues mentioned above have been addressed. Nothing from my side so I'll check it out and merge it soon...

Thanks for the addition.

@petk
Copy link
Member

petk commented Nov 14, 2018

Applied via ee939b7 into master branch since the PHP 7.3 is in bug fixes mode only, new feature change noted via 698f8be

In case I've missed something let me know. Thank you @DASPRiD

@petk petk closed this Nov 14, 2018
@petk
Copy link
Member

petk commented Nov 14, 2018

Anyone knows or has some suggestions maybe how we should document new functions such as this one? Do we wait and add it to the docs later in the process or is it suitable to be added now already at https://php.net/manual/en/book.openssl.php
?

@cmb69
Copy link
Member

cmb69 commented Nov 14, 2018

Anyone knows or has some suggestions maybe how we should document new functions such as this one?

Most important is to note all changes that require documentation in UPGRADING, too (also adding a link to the PR or RFC appears reasonable). This file serves as base for the migration guide, and users certainly want to know about all new functions (etc.)

Whether it's better to document the actual change in the manual proper (i.e. not in the migration guide) right away or sometimes later, is of secondary concern, and may be arguable. I prefer the former, mostly because I find it easier to document freshly written or reviewed code than old stuff, and particularly for new functions (etc.) because I can create the basic documentation using docgen right away.

@petk
Copy link
Member

petk commented Nov 15, 2018

UPGRADING file updated via 35a9ec1

jrfnl added a commit to PHPCompatibility/PHPCompatibility that referenced this pull request Jun 14, 2019
> - Core:
>    Added get_mangled_object_vars($object) function, which returns the mangled
>    object properties. It returns the same result as (array) $object, with the
>    exception that it ignores overloaded array casts, such as used by
>    ArrayObject.
>
> - OpenSSL:
>    Added openssl_x509_verify(mixed cert, mixed key) function that verifies the
>    signature of the certificate using a public key. A wrapper around the
>    OpenSSL's X509_verify() function.
>    See <php/php-src#3624>.
>
> - Pcntl:
>    Added bool pcntl_unshare(int flags) function which allows to dissociate
>    parts of the process execution context which are currently being shared with
>    other processes. Explicitly, it allows you to unshare the mount, IPC, UTS,
>    network, PID, user and cgroup namespaces.
>
> - SQLite3:
>    Added SQLite3Stmt::getSQL() to retrieve the SQL of the statement. If TRUE is
>    passed as parameter, query parameters will be replaced in the return value
>    by their currently bound value, if libsqlite ≥ 3.14 is used.
>
> - Standard
>    * bool sapi_windows_set_ctrl_handler(callable handler, [, bool add = true]) -
>       set or remove a handler function upon receiving a CTRL event. The handler
>       function is expected have a signature "function handler(int $event)".
>    * bool sapi_windows_generate_ctrl_event(int type, int pid) - send a CTRL event
>       to another process.

Refs:
* https://github.com/php/php-src/blob/42cc58ff7b2fee1c17a00dc77a4873552ffb577f/UPGRADING#L348-L379
jrfnl added a commit to PHPCompatibility/PHPCompatibility that referenced this pull request Jun 14, 2019
> - Core:
>    Added get_mangled_object_vars($object) function, which returns the mangled
>    object properties. It returns the same result as (array) $object, with the
>    exception that it ignores overloaded array casts, such as used by
>    ArrayObject.
>
> - OpenSSL:
>    Added openssl_x509_verify(mixed cert, mixed key) function that verifies the
>    signature of the certificate using a public key. A wrapper around the
>    OpenSSL's X509_verify() function.
>    See <php/php-src#3624>.
>
> - Pcntl:
>    Added bool pcntl_unshare(int flags) function which allows to dissociate
>    parts of the process execution context which are currently being shared with
>    other processes. Explicitly, it allows you to unshare the mount, IPC, UTS,
>    network, PID, user and cgroup namespaces.
>
> - Standard
>    * bool sapi_windows_set_ctrl_handler(callable handler, [, bool add = true]) -
>       set or remove a handler function upon receiving a CTRL event. The handler
>       function is expected have a signature "function handler(int $event)".
>    * bool sapi_windows_generate_ctrl_event(int type, int pid) - send a CTRL event
>       to another process.

Refs:
* https://github.com/php/php-src/blob/42cc58ff7b2fee1c17a00dc77a4873552ffb577f/UPGRADING#L348-L379
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants