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
New option: Add server certs to client chain #1014
Merged
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0169271
New option: Add server certs to client chain
ikoz 9b970b0
fix for sslinfo cert chain printing bug - now all certs get printed
ikoz 776e625
Add tests for add-server-certs-to-client-chain feature
ikoz efc3e94
Restructuring of the AddServerCertsToClientChain test so that it uses…
ikoz d26c7f4
Move more init things inside AddServerCertsToClientChainMixin
ikoz 02e3784
Create mutually exclusive group for add-server-certs-to-client-chain …
ikoz 9cc55f2
Rename 'server' to 'upstream' in identifiers related to the AddServer…
ikoz 8ed4912
Revert "Create mutually exclusive group for add-server-certs-to-clien…
ikoz b4e7aaf
Make the add-server-certs-to-client-chain and verify-upstream-cert op…
ikoz File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -999,3 +999,50 @@ def handler(f): | |
# (both terminated) | ||
# nothing happened here | ||
assert self.chain[1].tmaster.state.flow_count() == 2 | ||
|
||
|
||
class AddServerCertsToClientChainMixin: | ||
|
||
def test_add_server_certs_to_client_chain(self): | ||
with open(self.servercert, "rb") as f: | ||
d = f.read() | ||
c1 = SSLCert.from_pem(d) | ||
p = self.pathoc() | ||
server_cert_found_in_client_chain = False | ||
for cert in p.server_certs: | ||
if cert.digest('sha256') == c1.digest('sha256'): | ||
server_cert_found_in_client_chain = True | ||
break | ||
assert(server_cert_found_in_client_chain == self.add_server_certs_to_client_chain) | ||
|
||
|
||
class TestHTTPSAddServerCertsToClientChainTrue(tservers.HTTPProxyTest, AddServerCertsToClientChainMixin): | ||
|
||
""" | ||
If --add-server-certs-to-client-chain is True, then the client should receive the server's certificates | ||
""" | ||
add_server_certs_to_client_chain = True | ||
ssl = True | ||
servercert = tutils.test_data.path("data/trusted-server.crt") | ||
ssloptions = pathod.SSLOptions( | ||
cn="trusted-cert", | ||
certs=[ | ||
("trusted-cert", servercert) | ||
] | ||
) | ||
|
||
|
||
class TestHTTPSAddServerCertsToClientChainFalse(tservers.HTTPProxyTest, AddServerCertsToClientChainMixin): | ||
|
||
""" | ||
If --add-server-certs-to-client-chain is False, then the client should not receive the server's certificates | ||
""" | ||
add_server_certs_to_client_chain = False | ||
ssl = True | ||
servercert = tutils.test_data.path("data/trusted-server.crt") | ||
ssloptions = pathod.SSLOptions( | ||
cn="trusted-cert", | ||
certs=[ | ||
("trusted-cert", servercert) | ||
] | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Excellent. I think we can even move |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good find, thanks! 😃