Skip to content

[Docs] Improve openssl_x509_verify() to indicate that the return value is dangerous #4574

Open
@TimWolla

Description

@TimWolla

Affected page

https://www.php.net/manual/en/function.openssl-x509-verify.php

Current issue

Returns 1 if the signature is correct, 0 if it is incorrect, and -1 on error.

This means that both the success case and the error cases are truthy, which makes code like:

if (openssl_x509_verify()) { … }

dangerous.

Suggested improvement

A warning should be added to always compare === 1. The code example should be updated to === 1 instead of == 1 as well.

Additional context

Same applies to openssl_verify() and possibly others.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions