Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly mark check as failed for expired certificates #3

Merged
merged 1 commit into from
Oct 12, 2023
Merged

Properly mark check as failed for expired certificates #3

merged 1 commit into from
Oct 12, 2023

Conversation

JaZo
Copy link
Contributor

@JaZo JaZo commented Oct 11, 2023

Description

I fixed two bugs causing the check to crash on expired certificates and marking the check as success for expired certificates.

Motivation and context

When you check a domain with an expired certificate, the check crashes with the following exception:

Could not download certificate for host expired.badssl.com because Could not connect to expired.badssl.com:443.

Based on the documentation you should skip certificate verification when downloading expired certificates. Besides that, the logic to see if the certificate has expired is incorrect.

Current logic (bad)

echo Carbon::now()->addMonth()->diffInDays(); // 30
echo Carbon::now()->subMonth()->diffInDays(); // 30

New logic (correct)

echo Carbon::now()->diffInDays(Carbon::now()->addMonth(), false); // 31
echo Carbon::now()->diffInDays(Carbon::now()->subMonth(), false); // -29

How has this been tested?

I added new tests.

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@VictoRD11
Copy link
Owner

Thanks <3

@VictoRD11 VictoRD11 merged commit 7040cc6 into VictoRD11:main Oct 12, 2023
0 of 4 checks passed
@JaZo
Copy link
Contributor Author

JaZo commented Oct 13, 2023

You're welcome! Would you be so kind to add the hacktoberfest topic to the repository or the hacktoberfest-accepted label to this PR? 😃 You can find more info on https://hacktoberfest.com/participation/#pr-mr-details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants