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

A functional rustls-cert-gen with basic parameters. #190

Merged
merged 8 commits into from
Dec 20, 2023

Conversation

tbro
Copy link
Contributor

@tbro tbro commented Nov 13, 2023

This is basically #185 minus #188 and #189. The structure also differs as sub modules have been inlined in main.rs and cert.rs. anyhow has also been added as a dependency to replace the Result alias.

Closes #175

Copy link
Member

@cpu cpu left a comment

Choose a reason for hiding this comment

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

Thanks! Here's another round of feedback

Cargo.toml Outdated Show resolved Hide resolved
rustls-cert-gen/README.md Outdated Show resolved Hide resolved
rustls-cert-gen/src/cert.rs Outdated Show resolved Hide resolved
rustls-cert-gen/src/cert.rs Outdated Show resolved Hide resolved
rustls-cert-gen/src/cert.rs Outdated Show resolved Hide resolved
rustls-cert-gen/src/cert.rs Outdated Show resolved Hide resolved
rustls-cert-gen/src/cert.rs Outdated Show resolved Hide resolved
rustls-cert-gen/src/cert.rs Outdated Show resolved Hide resolved
rustls-cert-gen/src/cert.rs Outdated Show resolved Hide resolved
rustls-cert-gen/src/main.rs Outdated Show resolved Hide resolved
@tbro tbro force-pushed the rustls-cert-gen-basic-functionality branch 3 times, most recently from a8b1b9e to 34c6919 Compare November 14, 2023 22:29
@tbro
Copy link
Contributor Author

tbro commented Nov 14, 2023

Thanks! Here's another round of feedback

I think I have addressed everything in that round.

@cpu
Copy link
Member

cpu commented Nov 14, 2023

Thank you! I will do another pass in the next day or two.

@tbro tbro force-pushed the rustls-cert-gen-basic-functionality branch 2 times, most recently from 42fc2a5 to 2ab513c Compare December 4, 2023 20:13
Copy link
Member

@cpu cpu left a comment

Choose a reason for hiding this comment

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

Sorry for the delay getting this another review. I only have small nits to flag. I think there's likely good future work (like supporting a way to override the validity period), but I'm leaning towards trying to land this ASAP and iterating from there.

rustls-cert-gen/src/cert.rs Outdated Show resolved Hide resolved
rustls-cert-gen/src/cert.rs Outdated Show resolved Hide resolved
rustls-cert-gen/src/lib.rs Outdated Show resolved Hide resolved
rustls-cert-gen/src/cert.rs Outdated Show resolved Hide resolved
rustls-cert-gen/src/cert.rs Outdated Show resolved Hide resolved
rustls-cert-gen/src/lib.rs Outdated Show resolved Hide resolved
rustls-cert-gen/src/main.rs Outdated Show resolved Hide resolved
rustls-cert-gen/src/main.rs Outdated Show resolved Hide resolved
rustls-cert-gen/src/main.rs Show resolved Hide resolved
@cpu cpu requested a review from est31 December 5, 2023 21:49
@tbro tbro force-pushed the rustls-cert-gen-basic-functionality branch from 608ddd4 to 690fa6b Compare December 6, 2023 15:51
@tbro
Copy link
Contributor Author

tbro commented Dec 6, 2023

Sorry for the delay getting this another review. I only have small nits to flag. I think there's likely good future work (like supporting a way to override the validity period), but I'm leaning towards trying to land this ASAP and iterating from there.

Yes I also thought of the validity periods. I'm sure there are a few more features that could be added. But my preference is also to finish this first bit. Then it should be much easier to review smaller future PRs that target specific features/enhancements.

@tbro
Copy link
Contributor Author

tbro commented Dec 6, 2023

I believe latest review comments have been addressed.

Copy link
Member

@cpu cpu left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@djc djc left a comment

Choose a reason for hiding this comment

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

I have a few minor nits (hope these are not contradicting any earlier feedback), this looks good to me!

pem = { workspace = true, optional = true }
time = { version = "0.3.6", default-features = false }
x509-parser = { version = "0.15", features = ["verify"], optional = true }
x509-parser = { workspace = true, features = ["verify"], optional = true }
Copy link
Member

Choose a reason for hiding this comment

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

Personally I would prefer specifying all dependency versions at the workspace level, because otherwise it's not very clear when adding a dependency where to look.

params.distinguished_name = DistinguishedName::new();
Self { params }
}
/// Set signature algorithm (instead of default).
Copy link
Member

Choose a reason for hiding this comment

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

Please add empty lines between all the methods.

}
}

/// Builder to configure TLS [CertificateParams] to be finalized
Copy link
Member

Choose a reason for hiding this comment

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

I think usually we link names with both backticks and brackets, like [`CertificateParams`].

self.params.key_pair = Some(keypair);
Ok(self)
}
/// Set options for Ca Certificates
Copy link
Member

Choose a reason for hiding this comment

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

Should probably be [`Ca`], let's not capitalize "Certificates" here?

use std::{fmt, fs::File, io, path::Path};

#[derive(Debug, Clone)]
/// PEM serialized Certificate and PEM serialized corresponding private key
Copy link
Member

Choose a reason for hiding this comment

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

In terms of item ordering I think it would make more sense to keep PemCertifiedKey closer to EndEntity and Certificate, also keeping EndEntityBuilder and CaBuilder together.

This is basically rustls#185 minus rustls#188 and rustls#189. The structure also differs
as sub modules have been inlined in `main.rs` and `cert.rs`. `anyhow`
has also been added as a dependency to replace the `Result` alias.

Closes rustls#175

includes review fixes such as:

  * remove top-level rsa dependency
  * inline parse_san
  * Check for presence of EKU before pushing.
  * Replace `struct Signature` struct w/ `enum KeypairAlgorithm`
  * update some doc strings
  * make EndEntity and Ca public so they appear in the docs
  * additional test cases
@tbro tbro force-pushed the rustls-cert-gen-basic-functionality branch from 690fa6b to 6cb4b30 Compare December 11, 2023 17:11
@cpu
Copy link
Member

cpu commented Dec 14, 2023

exclude rustls-cert-gen from semver check

Why is this necessary - because there's no initial published verison? Can you add context motivating the change to the commit message?

`semver-checks` fail in CI because there is no published version of
`rustls-cert-gen`. excluding it seems like the simplest fix for the
moment. other workarounds can be found here: https://github.com/obi1kenobi/cargo-semver-checks#does-the-crate-im-checking-have-to-be-published-on-cratesio
@tbro tbro force-pushed the rustls-cert-gen-basic-functionality branch from de651d5 to 46efa11 Compare December 14, 2023 19:19
@tbro
Copy link
Contributor Author

tbro commented Dec 14, 2023

exclude rustls-cert-gen from semver check

Why is this necessary - because there's no initial published verison? Can you add context motivating the change to the commit message?

Yes I'm working around CI failure due to there no published version of rustls-cert-gen. I have updated commit message as requested.

@cpu
Copy link
Member

cpu commented Dec 14, 2023

Makes sense, thank you!

tbro added 4 commits December 14, 2023 13:51
Recent updates to `rcgen` resulted in an error on key generation. This
address that by mapping ring's `Error::Unspecified` to `rcgen::Error::RingUnspecified`.
Specify previous versions of the dependencies to support a minimum
rustc version of `1.69` and pass CI checks.
@tbro
Copy link
Contributor Author

tbro commented Dec 19, 2023

Hello everyone. Since we have 3 approvals can we go ahead and merge this? Pretty much every merge into main is causing conflicts requiring manual conflict resolution. In some cases changes to code. I have left these resolutions as separate commits above with clear messages, so they can easily be reviewed. I am happy to squash them all together given your go ahead. I fear if this PR is left sitting around the burden will become too much to keep up with. I understand that there are a few comments remaining above, but they are self-described as "minor nits". I suggest we move those to a separate issue . Feel free to assign it to me.

@cpu
Copy link
Member

cpu commented Dec 20, 2023

Hello everyone. Since we have 3 approvals can we go ahead and merge this?

That sounds good to me, I've been waiting for the branch to build green in CI again and it looks like that's been addressed. Thanks!

@djc @est31 Any reservations about merging this?

@est31
Copy link
Member

est31 commented Dec 20, 2023

I'm fine with merging!

@est31
Copy link
Member

est31 commented Dec 20, 2023

(and thanks @tbro for your contribution)

@cpu
Copy link
Member

cpu commented Dec 20, 2023

I'm fine with merging!

Cool, thanks for chiming in. I'm going to put it in the queue. Talking to Djc OOB I don't think he'll have a chance to look at this. If he does later we can tackle feedback in follow-up PRs.

(and thanks @tbro for your contribution)

+1!

@cpu cpu added this pull request to the merge queue Dec 20, 2023
Merged via the queue into rustls:main with commit 6637060 Dec 20, 2023
20 checks passed
@tbro tbro deleted the rustls-cert-gen-basic-functionality branch December 21, 2023 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Command line tool
4 participants