WordPress / WordPress/Requests

Investigate failing test for revoked certificate

Open
#966 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Component: Transports Status: help wanted Type: bug Type: testing/chores/QA
Dominant language
PHP
Stars
3.6k
Forks
500
Avg merge
2d 21h
Merged PRs (30d)
5

Description

PR #967 has marked the Transport\Curl\BaseTestCase::testRevokedHTTPS() test(s) as skipped as the tests were failing.

First off, the original URL we were using - https://testssl-revoked.disig.sk/index.en.html - no longer worked.

This was causing the tests to fail like so:

2) WpOrg\Requests\Tests\Transport\Curl\CurlTest::testRevokedHTTPS
Failed asserting that exception message 'cURL error 60: SSL certificate problem: self-signed certificate' contains 'certificate subject name'.

4) WpOrg\Requests\Tests\Transport\Fsockopen\FsockopenTest::testRevokedHTTPS
Failed asserting that exception message 'stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:
error:0A000086:SSL routines::certificate verify failed
stream_socket_client(): Failed to enable crypto
stream_socket_client(): unable to connect to ssl://testssl-revoked.disig.sk:443 (Unknown error)' contains 'SSL certificate did not match the requested domain name'.

This was fixed in PR #967 by switching the URL used in the tests to the https://revoked.badssl.com/ URL.

However, now the tests are still failing:

There were 2 failures:

1) WpOrg\Requests\Tests\Transport\Curl\CurlTest::testRevokedHTTPS
Failed asserting that exception of type "WpOrg\Requests\Exception" is thrown.

2) WpOrg\Requests\Tests\Transport\Fsockopen\FsockopenTest::testRevokedHTTPS
Failed asserting that exception of type "WpOrg\Requests\Exception" is thrown.

This indicates there is an underlying problem with the Request code and/or the test.

According to some unknown source:

Certificate revocation checking is not enabled by default in PHP's cURL or fsockopen. The certificate is technically valid (not expired, proper domain), it's just been revoked, but that's only checked if you explicitly enable OCSP/CRL checking.

Tasks:

  1. The above statement about PHP needs to be confirmed.
  2. We'd then need to decide how Requests should handle this. (ignore the revocation as it apparently does now, or throw an exception, which appears to be the behaviour the original design planned for)
  3. Based on what direction is chosen, the code and/or the tests need updating.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Transport\Curl\BaseTestCase::testRevokedHTTPS() and the corresponding CurlTest and FsockopenTest cases, then review PR #967 and the current revoked.badssl.com behavior. Confirm PHP's cURL and fsockopen revocation-checking behavior before deciding whether Requests should ignore revocation or throw an exception. Done means the chosen behavior is documented by passing tests and any required code changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
security, testing-qa
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.