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

TlsCreds: Support revocation of intermediate in chain. #32544

Merged
merged 5 commits into from
Mar 23, 2023

Conversation

gtcooke94
Copy link
Contributor

@gtcooke94 gtcooke94 commented Mar 3, 2023

This PR is a small code change with a lot of new test data.
In OpenSSL, there are two flags that configure CRL checks. Coping relevant section:

  • X509_V_FLAG_CRL_CHECK enables CRL checking for the certificate chain leaf certificate. An error occurs if a suitable CRL cannot be found.
  • X509_V_FLAG_CRL_CHECK_ALL enables CRL checking for the entire certificate chain.

We currently only set X509_V_FLAG_CRL_CHECK, so we will only ever check if the leaf certificate is revoked. We should check the whole chain. I am open to making this a user configuration if we want to do it that way, but we certainly need to be able to check the whole chain.

So, this PR contains the small code change in ssl_transport_security.cc to use the X509_V_FLAG_CRL_CHECK_ALL flag.
Then the rest of the changes are in tests. I've added all the necessary files to have a chain built that looks as follows
Root CA -> Revoked Intermediate CA -> Leaf Certificate, and added a test for this case as well.
You can verify that on master this new test will fail (i.e. the handshake will succeed even though the intermediate CA is revoked) by checking out this branch, running git checkout master -- ./src/core/tsi/ssl_transport_security.cc, then running the test.

I also slightly reorganized test/core/tsi/test_creds/ so that the CRLs are in their own directory, which is the way our API intends to accept CRLs.

Add files and slightly reorganize test/core/tsi/test_creds/ to add a
test that checks revoking an intermediate certificate in the chain. Add
`X509_V_FLAG_CRL_CHECK_ALL` to X509_VERIFY_PARAMs to indiciate to
OpenSSL that we want to check the whole chain, not just the leaf.
@gtcooke94 gtcooke94 added area/security release notes: yes Indicates if PR needs to be in release notes labels Mar 8, 2023
@markdroth markdroth changed the title Support revocation of intermediate in chain. TlsCreds: Support revocation of intermediate in chain. Mar 22, 2023
@gtcooke94 gtcooke94 merged commit a4f345f into grpc:master Mar 23, 2023
@copybara-service copybara-service bot added the imported Specifies if the PR has been imported to the internal repository label Mar 23, 2023
XuanWang-Amos pushed a commit to XuanWang-Amos/grpc that referenced this pull request May 1, 2023
This PR is a small code change with a lot of new test data.
[In OpenSSL, there are two flags that configure CRL checks. Coping
relevant
section:](https://www.openssl.org/docs/man1.0.2/man3/X509_VERIFY_PARAM_get_depth.html)

> - X509_V_FLAG_CRL_CHECK enables CRL checking for the certificate chain
leaf certificate. An error occurs if a suitable CRL cannot be found.
> - X509_V_FLAG_CRL_CHECK_ALL enables CRL checking for the entire
certificate chain.

We currently only set `X509_V_FLAG_CRL_CHECK`, so we will only ever
check if the leaf certificate is revoked. We should check the whole
chain. I am open to making this a user configuration if we want to do it
that way, but we certainly need to be able to check the whole chain.

So, this PR contains the small code change in
`ssl_transport_security.cc` to use the `X509_V_FLAG_CRL_CHECK_ALL` flag.
Then the rest of the changes are in tests. I've added all the necessary
files to have a chain built that looks as follows
`Root CA -> Revoked Intermediate CA -> Leaf Certificate`, and added a
test for this case as well.
You can verify that on master this new test will fail (i.e. the
handshake will succeed even though the intermediate CA is revoked) by
checking out this branch, running `git checkout master --
./src/core/tsi/ssl_transport_security.cc`, then running the test.

I also slightly reorganized test/core/tsi/test_creds/ so that the CRLs
are in their own directory, which is the way our API intends to accept
CRLs.
wanlin31 pushed a commit that referenced this pull request May 18, 2023
This PR is a small code change with a lot of new test data.
[In OpenSSL, there are two flags that configure CRL checks. Coping
relevant
section:](https://www.openssl.org/docs/man1.0.2/man3/X509_VERIFY_PARAM_get_depth.html)

> - X509_V_FLAG_CRL_CHECK enables CRL checking for the certificate chain
leaf certificate. An error occurs if a suitable CRL cannot be found.
> - X509_V_FLAG_CRL_CHECK_ALL enables CRL checking for the entire
certificate chain.

We currently only set `X509_V_FLAG_CRL_CHECK`, so we will only ever
check if the leaf certificate is revoked. We should check the whole
chain. I am open to making this a user configuration if we want to do it
that way, but we certainly need to be able to check the whole chain.

So, this PR contains the small code change in
`ssl_transport_security.cc` to use the `X509_V_FLAG_CRL_CHECK_ALL` flag.
Then the rest of the changes are in tests. I've added all the necessary
files to have a chain built that looks as follows
`Root CA -> Revoked Intermediate CA -> Leaf Certificate`, and added a
test for this case as well.
You can verify that on master this new test will fail (i.e. the
handshake will succeed even though the intermediate CA is revoked) by
checking out this branch, running `git checkout master --
./src/core/tsi/ssl_transport_security.cc`, then running the test.

I also slightly reorganized test/core/tsi/test_creds/ so that the CRLs
are in their own directory, which is the way our API intends to accept
CRLs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/security bloat/none imported Specifies if the PR has been imported to the internal repository lang/c++ lang/core lang/Python per-call-memory/neutral per-channel-memory/neutral release notes: yes Indicates if PR needs to be in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants