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

crypto: add validFromDate and validToDate fields to X509Certificate #54159

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RulerOfCakes
Copy link
Contributor

@RulerOfCakes RulerOfCakes commented Aug 1, 2024

Resolves #52931.

Since OpenSSL already provides validity checking based on the current time, it may be handy to provide such checks as a part of the X509Certificate API exposed by node. I have made some simple changes to provide such functionality using the default behavior of X509_cmp_timeframe() provided by OpenSSL.

Edit: Instead of providing the user with the date string format provided by OpenSSL's formatting for ASN.1 time objects, I have added parsing logic accordingly to provide them in the form of Javascript Date objects instead to make user interaction easier with these fields.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/crypto

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Aug 1, 2024
@RulerOfCakes RulerOfCakes changed the title crypto: add new isValid property for X509Certificate crypto: change validFrom and validTo fields of X509Certificate to Date Aug 5, 2024
lib/internal/crypto/x509.js Outdated Show resolved Hide resolved
lib/internal/crypto/x509.js Outdated Show resolved Hide resolved
@RulerOfCakes RulerOfCakes changed the title crypto: change validFrom and validTo fields of X509Certificate to Date crypto: add validFromDate and validToDate fields to X509Certificate Aug 6, 2024
doc/api/crypto.md Outdated Show resolved Hide resolved
doc/api/crypto.md Outdated Show resolved Hide resolved
Copy link

codecov bot commented Aug 7, 2024

Codecov Report

Attention: Patch coverage is 86.95652% with 6 lines in your changes missing coverage. Please review.

Project coverage is 87.32%. Comparing base (75d25bc) to head (a88395d).
Report is 43 commits behind head on main.

Files Patch % Lines
src/crypto/crypto_x509.cc 84.61% 0 Missing and 4 partials ⚠️
lib/internal/crypto/x509.js 90.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #54159      +/-   ##
==========================================
+ Coverage   87.09%   87.32%   +0.23%     
==========================================
  Files         648      648              
  Lines      182250   182367     +117     
  Branches    34967    34977      +10     
==========================================
+ Hits       158732   159255     +523     
+ Misses      16797    16376     -421     
- Partials     6721     6736      +15     
Files Coverage Δ
lib/internal/crypto/x509.js 92.01% <90.00%> (+9.67%) ⬆️
src/crypto/crypto_x509.cc 72.65% <84.61%> (+0.45%) ⬆️

... and 57 files with indirect coverage changes

@RulerOfCakes RulerOfCakes force-pushed the x509-is-valid branch 2 times, most recently from 501fc75 to 8ae70d3 Compare August 8, 2024 14:11
@pimterry pimterry added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 12, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 12, 2024
@nodejs-github-bot

This comment was marked as outdated.

Copy link
Member

@mertcanaltin mertcanaltin left a comment

Choose a reason for hiding this comment

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

lgtm

@daeyeon daeyeon added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 16, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 16, 2024
@nodejs-github-bot

This comment was marked as outdated.

@RulerOfCakes
Copy link
Contributor Author

sorry for the messy CI. I didn't realize timegm was unavailable cross-platform, so I'm trying to figure out an alternative but can't really test all these environments in my local environment. The previous C++ standard library based one seemed to produce some weird errors(which I think might be related to daylight savings), so I've changed it to a C-based one.

@daeyeon Could you please help me check if it works now in the CI?

@daeyeon daeyeon added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 17, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 17, 2024
@nodejs-github-bot

This comment was marked as outdated.

@daeyeon daeyeon added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 17, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 17, 2024
@nodejs-github-bot

This comment was marked as outdated.

Added equivalent fields to `X509Certificate` in Date form.
@daeyeon daeyeon added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 18, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 18, 2024
@nodejs-github-bot
Copy link
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/61190/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a valid property to X509Certificate
7 participants