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.
Motivation #274, based off #269 (comment)
Still required before merge:
Questions
rustls_cert_gen::Ca
?We could either keep it as a wrapper type of
rcgen::Issuer
or phase it out completely.If we were gonna phase it out I would do it with the following changes:
rustls_cert_gen::Ca
in favor ofrcgen::Issuer
rcgen::Issuer
torcgen::CertifiedKey
usingFrom
orto_certified_key
method.rcgen::PemCertifiedKey::write
torcgen::CertifiedKey::write_pem
(replacingCa::serialize_pem().write
withIssuer::to_certified_key().write_pem()
, alternatively we could also just haveIssuer::write_pem
)rustls_cert_gen::PemCertifiedKey
in favor ofrcgen::CertifiedKey
(which is fine because the method is nowwrite_pem
notwrite
)rustls_cert_gen::EndEntity::serialize_pem
and provide conversion fromrustls_cert_gen::EndEntity
torcgen::CertifiedKey
usingFrom
orto_certified_key
method.rustls_cert_gen::EndEntity
just bercgen::CertifiedKey
or is that too far?KeyPair
andClone
?I have removed the lifetime from
Issuer
so it holds owned values, as I personally think this is the best call and it was implied by @djc's message linked above.This does raise an interesting concern, how should
CertificateParams::self_signed
construct anrcgen::Issuer
as it takes in&KeyPair
and we would require an ownedKeyPair
.Options:
Clone
publically forKeyPair
and makeCertificateParams::self_signed
takeKeyPair
Clone
privately forKeyPair
and use itIssuer
hold aCow<'a, KeyPair>
and provide anIssuer::to_owned
method which allocates the data and returnsIssuer<'static>
.Issuer
hold a lifetime to theKeyPair
Option 4 has the major downside that it makes parsing around an
Issuer
really difficult due to it always having a lifetime to some buffer. I know in my personal use ofrcgen
I load the issuer on startup and give it around to Tokio tasks, and it would be nice to avoid leaking memory as would be required with this option.rcgen::Issuer
vsrcgen::CertifiedKey
?Aren't these basically the same type.
rustls_cert_gen::Ca
being either a wrapper or replaced byrcgen::Issuer
means we need to provide a way to go from anIssuer
toCertificate
which we will use to replace/reimplement the existingrustls_cert_gen::Ca::cert
method.Given this, I think it seems logical that in code
Issuer
could be:which is
rcgen::CertifiedKey
.I could be missing something but if they are the same type I feel like unifying them into one makes sense and simplifies the public API.
TODO
Gotta do this as @djc noted in the linked message.