-
Notifications
You must be signed in to change notification settings - Fork 11
test: CRL fetching [WPB-19580] #2007
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
Open
SimonThormeyer
wants to merge
7
commits into
main
Choose a base branch
from
simon/test/fetch-crls-e2e-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+101
−23
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7cab765
test(e2ei): add CRL distribution point to stepca intermediate
SimonThormeyer 827352f
chore: set host port of CRL server at runtime
SimonThormeyer 2760083
test(e2ei/pki): add e2e test to fetch CRLs
SimonThormeyer af8c954
fixup! test(e2ei): add CRL distribution point to stepca intermediate
SimonThormeyer 18af73c
fixup! chore: set host port of CRL server at runtime
SimonThormeyer 683ec89
chore(e2ei/test): use custom reqwest client in `TestPkiEnvironmentHooks`
SimonThormeyer d326af2
fixup! test(e2ei): add CRL distribution point to stepca intermediate
SimonThormeyer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -104,24 +104,30 @@ fn generate_authority_config(cfg: &CaCfg) -> serde_json::Value { | |
| }) | ||
| } | ||
|
|
||
| const INTERMEDIATE_CERT_TEMPLATE: &str = r#" | ||
| { | ||
| "subject": "Wire Intermediate CA", | ||
| "keyUsage": ["certSign", "crlSign"], | ||
| "basicConstraints": { | ||
| "isCA": true, | ||
| "maxPathLen": 0 | ||
| }, | ||
| "nameConstraints": { | ||
| "critical": true, | ||
| "permittedDNSDomains": ["localhost", "stepca"], | ||
| "permittedURIDomains": ["wire.localhost"] | ||
| } | ||
| } | ||
| "#; | ||
|
|
||
| pub(crate) const ACME_PROVISIONER: &str = "wire"; | ||
| const ACME_PROVISIONER: &str = "wire"; | ||
| const PORT: ContainerPort = ContainerPort::Tcp(9000); | ||
| const CRL_DISTRIBUTION_POINT_PLACEHOLDER: &str = "__CRL_DISTRIBUTION_POINT__"; | ||
|
|
||
| fn intermediate_cert_template() -> String { | ||
| format!( | ||
| r#" | ||
| {{ | ||
| "subject": "Wire Intermediate CA", | ||
| "keyUsage": ["certSign", "crlSign"], | ||
| "basicConstraints": {{ | ||
| "isCA": true, | ||
| "maxPathLen": 0 | ||
| }}, | ||
| "nameConstraints": {{ | ||
| "critical": true, | ||
| "permittedDNSDomains": ["localhost", "stepca"], | ||
| "permittedURIDomains": ["wire.localhost"] | ||
| }}, | ||
| "crlDistributionPoints": ["{CRL_DISTRIBUTION_POINT_PLACEHOLDER}"] | ||
| }} | ||
| "# | ||
| ) | ||
| } | ||
|
|
||
| /// This returns the Smallstep certificate template for leaf certificates, i.e. the ones | ||
| /// issued by the intermediate CA. | ||
|
|
@@ -144,9 +150,13 @@ fn alter_configuration(host_volume: &Path, ca_cfg: &CaCfg) { | |
| let cfg_file = host_volume.join("config").join("ca.json"); | ||
| let cfg_content = std::fs::read_to_string(&cfg_file).unwrap(); | ||
| let mut cfg = serde_json::from_str::<serde_json::Value>(&cfg_content).unwrap(); | ||
| let authority = serde_json::to_string(&generate_authority_config(ca_cfg)).unwrap(); | ||
| cfg.as_object_mut() | ||
| .unwrap() | ||
| .insert("authority".to_string(), generate_authority_config(ca_cfg)); | ||
| .insert("authority".to_string(), serde_json::from_str(&authority).unwrap()); | ||
|
Member
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. Here we are calling like the previous version did? |
||
| cfg.as_object_mut() | ||
| .unwrap() | ||
| .insert("crl".to_string(), json!({ "enabled": true })); | ||
| std::fs::write(&cfg_file, serde_json::to_string_pretty(&cfg).unwrap()).unwrap(); | ||
| } | ||
|
|
||
|
|
@@ -180,7 +190,7 @@ pub(crate) async fn start_acme_server(ca_cfg: &CaCfg) -> AcmeServer { | |
| std::fs::set_permissions(&host_volume, permissions).unwrap(); | ||
| std::fs::write( | ||
| host_volume.join("intermediate.template"), | ||
| INTERMEDIATE_CERT_TEMPLATE.to_string().into_bytes(), | ||
| intermediate_cert_template().into_bytes(), | ||
| ) | ||
| .unwrap(); | ||
| } | ||
|
|
@@ -201,6 +211,18 @@ pub(crate) async fn start_acme_server(ca_cfg: &CaCfg) -> AcmeServer { | |
| .with_cmd(["bash", "-c", "sleep 1h"]); | ||
|
|
||
| let node = image.start().await.expect("Error running Step CA image"); | ||
| let crl_distribution_point = format!( | ||
| "https://{}:{}/1.0/crl", | ||
| ca_cfg.host, | ||
| node.get_host_port_ipv4(PORT).await.unwrap() | ||
| ); | ||
| std::fs::write( | ||
| host_volume.join("intermediate.template"), | ||
| intermediate_cert_template() | ||
| .replace(CRL_DISTRIBUTION_POINT_PLACEHOLDER, &crl_distribution_point) | ||
| .into_bytes(), | ||
| ) | ||
| .unwrap(); | ||
istankovic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Generate the root certificate. | ||
| run_command(&node, "bash -c 'dd if=/dev/random bs=1 count=20 | base64 > password'").await; | ||
|
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.