Skip to content

ref certbot/certbot#2163 EC cert generation support#7247

Closed
pahrohfit wants to merge 39 commits intocertbot:masterfrom
pahrohfit:ec-cert-support
Closed

ref certbot/certbot#2163 EC cert generation support#7247
pahrohfit wants to merge 39 commits intocertbot:masterfrom
pahrohfit:ec-cert-support

Conversation

@pahrohfit
Copy link
Copy Markdown

@pahrohfit pahrohfit commented Jul 15, 2019

Two new options:

  • --key-type -- Takes either 'rsa' or 'ec' as options (defaults to RSA for backwards compatibility).
  • --ec-key-size -- Takes [160, 224, 384, 521] as size, defaults to 384.

Did everything to maintain full backwards compatibility with existing code/plugins, so it could be prettier if that was abandoned.

Pull Request Checklist

  • Edit the master section of CHANGELOG.md to include a description of
    the change being made.
  • Add mypy type
    annotations

    for any functions that were added or modified.
  • Include your name in AUTHORS.md if you like.

@pahrohfit
Copy link
Copy Markdown
Author

Seems complete. Look forward to feedback.

Copy link
Copy Markdown
Collaborator

@adferrand adferrand left a comment

Choose a reason for hiding this comment

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

Hello @pahrohfit, and thanks a lot for your PR. Indeed the support of ECDSA cert is really expected, and was planned to be done by the Certbot core team next year. But if someone is willing to support the integration of this feature, we would gladly review the subsequent PRs to make the functionality available in Certbot.

On that matter, it is clear that ECDSA certificates is a major feature. So it needs to be carefully handled, in order to avoid regressions, erroneous/failed configurations or even post-release fallbacks. These events are more likely to happen and to have a major impact considering the number of Certbot users.

That is why this kind of feature is associated with a documented specification to organize its implementation. We try at most to gather and anticipate impacts, retro-compatibility considerations and usability in this document. For ECDSA certificates it can be found here: https://docs.google.com/document/d/1JaTZn-ZZeCJcg1j0D1RhIOl5B5joifRtqExGQTfzrAE/edit?usp=sharing

I invite you to read it and make your opinion about the work to do, and maybe propose ideas to improve it.

Then, would you be willing to contribute in a part or more of the integration path described in the document?

@adferrand adferrand self-assigned this Jul 16, 2019
@TaaviE
Copy link
Copy Markdown

TaaviE commented Aug 16, 2019

Is there anything blocking merging this as the foundation for future work? I don't think volunteer PRs can't be reasonably expected to implement every single feature specified in the design doc, I doubt even the team implements it all in one PR, this one here just provides the functionality to at least handle ECDSA keys properly which has been long due.

@gbdlin
Copy link
Copy Markdown

gbdlin commented Aug 23, 2019

@TaaviE IMO the parameter should be named --key-types and allow providing multiple values, also key for ECDSA cert should be ecdsa, as in specified document, not ec. For now, --key-types used with multiple cert types should throw an error that this is not yet supported (and for any other case that is not yet covered in your PR, like installing ECDSA certs). All of it should be done in that way, so we won't introduce backwards incompatible changes when implementing rest of the functionalities from this document.

@TaaviE
Copy link
Copy Markdown

TaaviE commented Aug 24, 2019

IMO the parameter should be named --key-types and allow providing multiple values, also key for ECDSA cert should be ecdsa, as in specified document, not ec. For now, --key-types used with multiple cert types should throw an error that this is not yet supported (and for any other case that is not yet covered in your PR, like installing ECDSA certs).

Okay, the design doc also says it should be --key-type (singular for some reason) but accepts multiple parameters (ecdsa and rsa).

@pahrohfit Could you make that small change please? Would you accept pull requests to your branch?

@pahrohfit
Copy link
Copy Markdown
Author

absolutely... i’ll get it done next day or so

rob added 3 commits September 3, 2019 11:35
…idation to allow multiple `--key-type` values, but report a parse error for more than one

Multiple `--key-type` values will be supported at a later time, when all of certbot can handle multiple key types during certificate generation.
@pahrohfit
Copy link
Copy Markdown
Author

absolutely... i’ll get it done next day or so

Completed and code checks passed

@pahrohfit
Copy link
Copy Markdown
Author

@adferrand thoughts on the above? Seems to have addressed the minimum requirements in the documentation set.

@pahrohfit pahrohfit requested a review from adferrand September 6, 2019 03:03
Copy link
Copy Markdown
Collaborator

@adferrand adferrand left a comment

Choose a reason for hiding this comment

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

Thanks a lot for you PR. In the scope of its purpose, I largely agree with the implementation. I have mainly few requests to add more tests and one question about how the flags are set by the CLI.

Now, I think we still need to decide about the strategy used by your PR here to implement EC certificates. Let's view the pro and cons.

Pros:

Your PR adds immediately, and with very few modifications, the EC certificate feature. And if someone does not use or is aware of --key-type, Certbot behavior stays exactly the same than before. Finally, naming convention follows the initial design, while the feature on its own does not add everything in a row, but only one deliverable unit of logic.

This is really a quick win.

Cons:

Depending on how --key-type is invoked for each certificates, standard paths live/[LINEAGE]/{cert,privkey,chain,fullchain}.pem will contain either an RSA or ECDSA key/cert.

  1. First drawback is that it is not obvious from the path if the files contain RSA or ECDSA stuff
  2. Second drawback is when multiple values will be authorized in --key-type. The idea was to suffix all files with -ecdsa for ECDSA stuff. Here with your PR merged, some migration path will be needed to handle the fact that one given path file may change from ECDSA to RSA based material when --key-type changes from ecdsa to rsa,ecdsa.

My opinion: let's merge it!

I think Pros win over Cons in the absolute, and the fact that this feature is waited by a lot of people adds one more motivation to merge this PR.

Concerning the first drawback: this can be fixed quickly in a future PR to change what certbot certificates displays. For now, having an ECDSA cert in the standard path is the result of an explicit action from the caller, and I think in this case he will be ready to make the appropriate modifications in any workflow to take that into account.

Concerning the second drawback: any modification to the paths used by certbot will imply a lot of modifications everywhere in the code, making the availability of EC certificates uncertain in a near future. I prefer to get it now, and deal with migration later, if this kind of migration is really needed.

Because in term of migration, I think it would make sense to use explicit and dedicated paths for both types (privkey-rsa.pem and privkey-ecdsa.pem) when --key-type is used with two values. On the contrary using the standard non explicit path is suitable for any single value on --key-type. I think it makes things clear, in particular for the dual-stack configuration since it will require explicit modifications outside certbot anyway to use that correctly. And finally I am not convinced that rsa,ecdsa should become the default value for --key-type in certbot (if you are interested to know why I think that, we can discuss it on another thread). In that case, there is no migration path to handle, it is just another way to use certbot.

Now I will invoke @bmw here to have a second opinion ^^

certbot/cli.py Outdated
"security", "--ecdsa-key-size", type=int, metavar="N",
default=flag_default("ecdsa_key_size"), help=config_help("ecdsa_key_size"))
helpful.add(
"security", "--key-type", type=str, choices=['rsa', 'ecdsa'], nargs="+",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

On top of the unit tests added here, I would like an integration test in certbot-ci/certbot_integration_tests/certbot_tests/test_main.py to check that certbot behaves as expected when the new flags are added. Typical scenarios I have in mind:

  • pass no flag or --key-type=rsa and expect a RSA key/cert generated with the default RSA size
  • pass --key-type=ecdsa and expect an ECDSA key/cert generated with the default ECDSA size
  • pass wrong --key-type and expect certbot to crash with the expected error message
  • handle key size control flags (ECDA and RSA) may be added in a modified version of the existing test test_renew_with_changed_private_key_complexity

@pahrohfit
Copy link
Copy Markdown
Author

Not sure why that one lint test is failing ... any suggestions?

Copy link
Copy Markdown
Author

@pahrohfit pahrohfit left a comment

Choose a reason for hiding this comment

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

Ready for review

@pahrohfit
Copy link
Copy Markdown
Author

Not sure why that one lint test is failing ... any suggestions?

Thanks for the heads up @adferrand

Copy link
Copy Markdown
Collaborator

@adferrand adferrand left a comment

Choose a reason for hiding this comment

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

Hello again @pahrohfit

I am still waiting for an integration test on the ECDSA feature, as in https://github.com/certbot/certbot/pull/7247/files#r321684775. Will you have the time to add it? Beside that, I added a remark to keep updating the changelog.

CHANGELOG.md Outdated

## 0.37.0 - 2019-09-03

### Added
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This entry should be removed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Will update that at the end

CHANGELOG.md Outdated

## 0.39.0 - 2019-09-05

### Added
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These entries should be moved up to the master section to be included in the next release changelog.

@rlaager
Copy link
Copy Markdown

rlaager commented Oct 31, 2019

2. Second drawback is when multiple values will be authorized in --key-type. The idea was to suffix all files with -ecdsa for ECDSA stuff. Here with your PR merged, some migration path will be needed to handle the fact that one given path file may change from ECDSA to RSA based material when --key-type changes from ecdsa to rsa,ecdsa.

@pahrohfit How hard would it be to change the existing PR to suffix things with -ecdsa to make the future dual-certificate support easier to merge?

@adferrand
Copy link
Copy Markdown
Collaborator

This is also a requirement @bmw and me have, for the very same reason that @rlaager just gave. And it will make clear what is the nature of a given certificate, since there is no display logic for that in certbot CLI so far.

@bmw bmw mentioned this pull request Oct 31, 2019
@pahrohfit
Copy link
Copy Markdown
Author

Hello again @pahrohfit

I am still waiting for an integration test on the ECDSA feature, as in https://github.com/certbot/certbot/pull/7247/files#r321684775. Will you have the time to add it? Beside that, I added a remark to keep updating the changelog.

Sorry, been traveling and changing jobs... yeap, working on the last tests now (also had to get a linux vm setup since I work on fbsd)

@bmw
Copy link
Copy Markdown
Member

bmw commented Nov 20, 2019

This is also a requirement @bmw and me have, for the very same reason that @rlaager just gave. And it will make clear what is the nature of a given certificate, since there is no display logic for that in certbot CLI so far.

I'd hold off on this piece for now. Since this comment was written, we've been having some conversations internally about the design here and may not need/want this piece.

@rlaager
Copy link
Copy Markdown

rlaager commented Nov 20, 2019

I withdraw my comment/request, too. It seems that ECDSA-only would be fine at this point.

This presentation from 2015 seems to suggest that ECDSA support in browsers is better than I might have expected: https://csrc.nist.gov/csrc/media/events/workshop-on-elliptic-curve-cryptography-standards/documents/presentations/session2-andrews-rick.pdf

More importantly, I just ran ssllabs.com against one of my websites (which is configured per current Mozilla SSL Generator guidance) and looked at each of the clients to determine what would be lost if I switched from RSA to ECDSA. It looks like I'd only lose "Chrome 49 / XP SP3", which I'm okay with.

@pahrohfit pahrohfit requested a review from adferrand November 20, 2019 15:43
@TaaviE TaaviE mentioned this pull request Jan 2, 2020
@TaaviE
Copy link
Copy Markdown

TaaviE commented Jan 2, 2020

@adferrand are the changes requested still actual or could this PR be finally merged?

@bmw
Copy link
Copy Markdown
Member

bmw commented Jan 3, 2020

The current status of this is we initially wanted the behavior in the design doc at https://docs.google.com/document/d/1JaTZn-ZZeCJcg1j0D1RhIOl5B5joifRtqExGQTfzrAE/edit?usp=sharing which is not implemented in this PR.

After talking about this internally though, we think some features there such as needing to support dual ECDSA and RSA certificates as part of supporting ECDSA certificates at all is no longer necessary.

We came up with some new design questions about Certbot's behavior and UI around this feature that need to be answered if we're deviating from that design though. We think this is important to get right initially because making changes to this stuff after the feature is released is painful.

I'm planning on proposing something to the core team, getting everyone's approval, and then posting the changes we want to see within the next month. This may be a little slower than what you want, but this PR/feature is on our radar and if you haven't heard from me by February, by all means mention me for another update.

@bmw
Copy link
Copy Markdown
Member

bmw commented Jan 31, 2020

I wrote a new design for Certbot's behavior around ECDSA subject keys which no one on the Certbot team has objected to at #2163 (comment).

@adferrand
Copy link
Copy Markdown
Collaborator

Hello @pahrohfit, are you willing to continue the work to align with the new design posted by @bmw, or do you want me to take this PR on my own ?

@pahrohfit
Copy link
Copy Markdown
Author

Yeap; just read it the other day, I’ll get to work on it this week. Seems must more straightforward than the last, so I’m good

@bmw bmw added the priority: unplanned Work that we believe should be done, but does not have a higher priority. label Mar 25, 2020
@adferrand
Copy link
Copy Markdown
Collaborator

Hello @pahrohfit, I updated your PR with master, to not let it rot. Are you still willing to work on it?

hrs-allbsd added a commit to hrs-allbsd/certbot that referenced this pull request Aug 15, 2020
@adferrand
Copy link
Copy Markdown
Collaborator

Since #8431 has been merged, which is based on top of your work @pahrohfit, I think we can close this PR.

@adferrand adferrand closed this Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: unplanned Work that we believe should be done, but does not have a higher priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants