Skip to content

tls: fix daysUntilFirstCertExpires#20581

Merged
zuercher merged 34 commits intoenvoyproxy:mainfrom
daixiang0:spiffe
May 12, 2022
Merged

tls: fix daysUntilFirstCertExpires#20581
zuercher merged 34 commits intoenvoyproxy:mainfrom
daixiang0:spiffe

Conversation

@daixiang0
Copy link
Copy Markdown
Member

Signed-off-by: Loong Dai loong.dai@intel.com

Commit Message: The root cause is that size_t is unsigned, and can thus only express positive numbers.
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA] #20573
[Optional Deprecated:]
[Optional API Considerations:]

@daixiang0
Copy link
Copy Markdown
Member Author

Another issue is that should we return a negative number for the day until first expired since it already expired?

@daixiang0
Copy link
Copy Markdown
Member Author

I feel that a real negative number is useless, just -1 is enough to mean it expired.

@daixiang0 daixiang0 requested a review from ggreenway as a code owner March 30, 2022 08:10
Signed-off-by: Loong Dai <loong.dai@intel.com>
Signed-off-by: Loong Dai <loong.dai@intel.com>
@daixiang0 daixiang0 changed the title tls: fix spiffe daysUntilFirstCertExpires tls: fix daysUntilFirstCertExpires Mar 31, 2022
Copy link
Copy Markdown
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

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

Thanks for fixing the bug!

@daixiang0
Copy link
Copy Markdown
Member Author

/wait for modifying

@daixiang0
Copy link
Copy Markdown
Member Author

/retest

@repokitteh-read-only
Copy link
Copy Markdown

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #20581 (comment) was created by @daixiang0.

see: more, trace.

Signed-off-by: Loong Dai <loong.dai@intel.com>
Signed-off-by: Loong Dai <loong.dai@intel.com>
Signed-off-by: Loong Dai <loong.dai@intel.com>
Signed-off-by: Loong Dai <loong.dai@intel.com>
@adisuissa adisuissa self-assigned this Apr 8, 2022
Signed-off-by: Loong Dai <loong.dai@intel.com>
Signed-off-by: Loong Dai <loong.dai@intel.com>
Signed-off-by: Loong Dai <loong.dai@intel.com>
Copy link
Copy Markdown
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this.

@adisuissa
Copy link
Copy Markdown
Contributor

another nit: you can use make_optional to create an optional value.

Signed-off-by: Loong Dai <loong.dai@intel.com>
@daixiang0
Copy link
Copy Markdown
Member Author

@adisuissa thanks for your review, I have updated all.

Signed-off-by: Loong Dai <loong.dai@intel.com>
Signed-off-by: Loong Dai <loong.dai@intel.com>
Signed-off-by: Loong Dai <loong.dai@intel.com>
Signed-off-by: Loong Dai <loong.dai@intel.com>
@zuercher
Copy link
Copy Markdown
Member

C++ exception with description "JSON value from line 1 is larger than int64_t (not supported)" thrown in the test body.

I expect that's to do with your change. Not sure if the limit is in our code or a library.

@daixiang0
Copy link
Copy Markdown
Member Author

daixiang0 commented Apr 29, 2022

It may be related to the that I change INT_MAX to SIZE_MAX.

Signed-off-by: Loong Dai <loong.dai@intel.com>
Signed-off-by: Loong Dai <loong.dai@intel.com>
Signed-off-by: Loong Dai <loong.dai@intel.com>
daixiang0 added 3 commits May 5, 2022 09:30
Signed-off-by: Loong Dai <loong.dai@intel.com>
Signed-off-by: Loong Dai <loong.dai@intel.com>
Signed-off-by: Loong Dai <loong.dai@intel.com>
* @return the number of days till this certificate is valid, the value is set when not expired.
*/
absl::optional<int32_t> getDaysUntilExpiration(const X509* cert, TimeSource& time_source);
absl::optional<size_t> getDaysUntilExpiration(const X509* cert, TimeSource& time_source);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should use uint32_t here as well?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure.

Copy link
Copy Markdown
Member

@zuercher zuercher left a comment

Choose a reason for hiding this comment

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

Just one more comment.

daixiang0 added 4 commits May 7, 2022 08:33
1
Signed-off-by: Loong Dai <loong.dai@intel.com>
Signed-off-by: Loong Dai <loong.dai@intel.com>
Signed-off-by: Loong Dai <loong.dai@intel.com>
Signed-off-by: Loong Dai <loong.dai@intel.com>
@daixiang0
Copy link
Copy Markdown
Member Author

@zuercher please review again.

Copy link
Copy Markdown
Member

@zuercher zuercher left a comment

Choose a reason for hiding this comment

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

Looks good. Let's add release notes indicating the change and then we can merge.

daixiang0 added 3 commits May 11, 2022 08:08
Signed-off-by: Loong Dai <loong.dai@intel.com>
Signed-off-by: Loong Dai <loong.dai@intel.com>
@zuercher zuercher merged commit 7fefd09 into envoyproxy:main May 12, 2022
@daixiang0 daixiang0 deleted the spiffe branch May 12, 2022 03:26
@jmarantz
Copy link
Copy Markdown
Contributor

I suspect there's an issue in this PR. Can we roll this back or quickly scrutinize it for unchecked accesses to optional values?

@mattklein123
Copy link
Copy Markdown
Member

@jmarantz there is an issue, see the open fix PR here: #21428

If we want to do a quick revert here while that PR is sorted that is fine with me.

@jmarantz
Copy link
Copy Markdown
Contributor

Yan just pointed out #21428 to me, thanks.

I don't think we need a revert -- we can deal with this locally for now and wait for the proper fix in flight.

ravenblackx pushed a commit to ravenblackx/envoy that referenced this pull request Jun 8, 2022
The root cause is that size_t is unsigned, and can thus only express positive numbers.

Risk Level: low
Testing: unit tests updated
Docs Changes: n/a
Release Notes: added
Fixes envoyproxy#20573

Signed-off-by: Loong Dai <loong.dai@intel.com>
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.

6 participants