Skip to content

tls: use X509_V_FLAG_NO_CHECK_TIME to implement allow_expired_certificate#23320

Merged
ggreenway merged 2 commits intoenvoyproxy:mainfrom
davidben:no-check-time
Oct 3, 2022
Merged

tls: use X509_V_FLAG_NO_CHECK_TIME to implement allow_expired_certificate#23320
ggreenway merged 2 commits intoenvoyproxy:mainfrom
davidben:no-check-time

Conversation

@davidben
Copy link
Copy Markdown
Contributor

@davidben davidben commented Sep 29, 2022

This PR includes PR #23319 as its first commit. For review, I'd suggest just looking at the second commit, and leaving the first commit to be reviewed in the base PR.

The intent was to upload a pair of dependent PRs. I've made them into separate PRs because it looked like you all prefer one commit per PR (since PR descriptions ask for a commit message), and it seemed worth keeping the changes ultimately separate. Let me know if this isn't the preferred workflow.

Update: #23319 is now merged, so this has been rebased on top of it.


Commit Message:
Newer revisions of BoringSSL provide OpenSSL's X509_V_FLAG_NO_CHECK_TIME API. Envoy currently implements allow_expired_certificate by using the X509_STORE_CTX verify callback. This callback is difficult for BoringSSL to support as it exposes internal details of the verification process. (What order errors come in, that there isn't a real path-builder, etc.) It also leaves X509_STORE_CTX in a funny state (per the error-reporting bug fixed before this commit).

This change replaces this callback with a more direct API. Without removing the callback, it will be very difficult to migrate Envoy to the future replacement certificate verifier in BoringSSL.

As Envoy doesn't track BoringSSL HEAD, and needs to support a very old boringssl_fips config, I've retained the callback-based path for when X509_V_FLAG_NO_CHECK_TIME is unavailable. Once Envoy's minimum BoringSSL revision is new enough, this can all be removed in favor of just calling X509_STORE_CTX_set_flags in default_validator.cc and spiffe_validator.cc.

utility_test.cc is removed because it wasn't actually testing anything, just that callback recognized a pair of return values, without even driving a certificate verification. The actual test coverage came from spiffe_validator_test and ssl_socket_test.

Signed-off-by: David Benjamin davidben@google.com

Additional Description:
Risk Level: Low
Testing: bazelist test //test/extensions/transport_sockets/tls/..., also with BoringSSL updated to HEAD to make sure both codepaths worked
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Copy link
Copy Markdown
Member

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

/wait

@repokitteh-read-only repokitteh-read-only bot added waiting deps Approval required for changes to Envoy's external dependencies and removed waiting labels Oct 3, 2022
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).
envoyproxy/dependency-shepherds assignee is @htuch

🐱

Caused by: #23320 was synchronize by davidben.

see: more, trace.

…cate

Newer revisions of BoringSSL provide OpenSSL's X509_V_FLAG_NO_CHECK_TIME
API. Envoy currently implements allow_expired_certificate by using the
X509_STORE_CTX verify callback. This callback is difficult for BoringSSL
to support as it exposes internal details of the verification process.
(What order errors come in, that there isn't a real path-builder, etc.)
It also leaves X509_STORE_CTX in a funny state (per the error-reporting
bug fixed before this commit).

This change replaces this callback with a more direct API. Without
removing the callback, it will be very difficult to migrate Envoy to the
future replacement certificate verifier in BoringSSL.

As Envoy doesn't track BoringSSL HEAD, and needs to support a very old
boringssl_fips config, I've retained the callback-based path for when
X509_V_FLAG_NO_CHECK_TIME is unavailable. Once Envoy's minimum BoringSSL
revision is new enough, this can all be removed in favor of just calling
X509_STORE_CTX_set_flags in default_validator.cc and
spiffe_validator.cc.

utility_test.cc is removed because it wasn't actually testing anything,
just that callback recognized a pair of return values, without even
driving a certificate verification. The actual test coverage came from
spiffe_validator_test and ssl_socket_test.

Signed-off-by: David Benjamin <davidben@google.com>
…certificate

Signed-off-by: David Benjamin <davidben@google.com>
@davidben
Copy link
Copy Markdown
Contributor Author

davidben commented Oct 3, 2022

Forced-pushed to rebase atop the merge of #23319.

Copy link
Copy Markdown
Member

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

LGTM

@ggreenway ggreenway enabled auto-merge (squash) October 3, 2022 21:32
@ggreenway
Copy link
Copy Markdown
Member

Forced-pushed to rebase atop the merge of #23319.

In the future, please merge instead of rebasing; it makes PRs to easier to review on github (due to github's poor support for rebasing).

@ggreenway ggreenway merged commit ad186c4 into envoyproxy:main Oct 3, 2022
davidben added a commit to davidben/envoy that referenced this pull request Nov 4, 2022
Both things the comment says are inaccurate: After envoyproxy#23320, this
mechanism no longer uses the X509_STORE callback, but a flag.
After envoyproxy#21417, Envoy is also not (always) using
SSL_CTX_set_cert_verify_callback, but a different one.

Just remove the comment altogether, as it doesn't seem to provide any
value. All it's saying is that, because Envoy still uses `store` at the
end of the day, configuring things on `store` does stuff. But the whole
function configures things on `store`, so it's not specific to that
block anyway.

Signed-off-by: David Benjamin <davidben@google.com>
lizan pushed a commit that referenced this pull request Nov 7, 2022
Both things the comment says are inaccurate: After #23320, this
mechanism no longer uses the X509_STORE callback, but a flag.
After #21417, Envoy is also not (always) using
SSL_CTX_set_cert_verify_callback, but a different one.

Just remove the comment altogether, as it doesn't seem to provide any
value. All it's saying is that, because Envoy still uses `store` at the
end of the day, configuring things on `store` does stuff. But the whole
function configures things on `store`, so it's not specific to that
block anyway.

Signed-off-by: David Benjamin <davidben@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deps Approval required for changes to Envoy's external dependencies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants