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

Add ECDSA support #2443

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from
Open

Conversation

OpenLarry
Copy link
Contributor

I added the ECDSA certificate support like we have discussed in #2426 .

I tried to modify the bash script as less as possible to reduce the time for code review/testing and I tried to use the same coding style like before. However, I decided to move some code into separate functions to avoid code duplication.

A few notes:

  • I did not add a separate option (at least not yet) to disable ECDSA certificates when using the integrated Letsencrypt client. I don't think that it makes sense to disable ECDSA, because there should be no drawback when it stays enabled for everyone?
  • If SKIP_LETSENCRYPT=y (or the installed certificate isn't issued by Letsencrypt) and there is no custom ECDSA cert, the script will add a symlink from the ECDSA certificate to the RSA certificate.
  • ECDSA and RSA certificates are checked and renewed independently from each other, so it's likely that they have different validity periods after migration.
  • I've combined this if-statement with the statement above. I think it's a bug to continue the script if there isn't a certificate, but we have an old one that has non-matching hashes. (However it should happen rarely - or even never?)

I've tested migration (using custom and Letsencrypt certificates) and fresh installations. I've checked all services using testssl.sh and it reports two certificates or one certificate depending on whether an ECDSA certificate exists or not. Looks good to me, so I'm looking forward to feedback! :-)

Of course I can add a few lines to the documentation as well.

Closes #2426

@andryyy
Copy link
Contributor

andryyy commented Mar 16, 2019

I have not looked into it at all. What about TLSA?
Any changes when updating?

I

@OpenLarry
Copy link
Contributor Author

Damn... yes.

Didn't think about that yet because I don't use DNSSEC.
A second certificate also requires a second TLSA record for each offered service.
The automatic generation of DNS records in Mailcow's UI could probably be extended easily to show the required records for both certificates.

But that makes migration from an RSA-only setup indeed more complex for users that are already using DNSSEC.

Any ideas how to solve that easily?

  • Check if TLSA records are present and disable the ECDSA certificate if it's not listed?
  • Show a warning during the update process and let the user decide (and add an option to disable the ECDSA certificates in mailcow.conf)?
  • Combination of both?

@andryyy
Copy link
Contributor

andryyy commented Mar 16, 2019

And that’s where hacky starts and delivery may fail.

@mkuron
Copy link
Member

mkuron commented Mar 16, 2019

That means we need a configuration option where users explicitly have to turn on ECDSA. I was hoping to avoid that (we have enough such options already), but there is no way around it. I guess we could turn it on by default on new installs though (from generate_config.sh).

@andryyy
Copy link
Contributor

andryyy commented Mar 17, 2019

Can we get docs for this? :)

@OpenLarry
Copy link
Contributor Author

Sure! :-) If the PR is ready to get merged and the functionality is more or less complete, then I'll add something about it to the documentation.

@andryyy
Copy link
Contributor

andryyy commented Mar 18, 2019

Looks complete. :) Do you think this is ready to be merged?

A few words in the docs are enough.

@OpenLarry
Copy link
Contributor Author

I've added a few words about it to documentation and I updated the chapter slightly. I hope it's all right. :-)

I tried to test my code with every scenario that came into my mind. So I hope it works. 😃

@OpenLarry
Copy link
Contributor Author

Is anything still missing here?
Do you need help? :-)

@patschi
Copy link
Member

patschi commented May 5, 2019

@andryyy Anything new in terms of merging this?

@Knight1
Copy link
Contributor

Knight1 commented Aug 5, 2019

I wonder what happens with all the Software when they load the same certificate twice.

@OpenLarry
Copy link
Contributor Author

OpenLarry commented Aug 7, 2019

I've already checked the services implementation and documentation here.

Since it's documented OpenSSL functionality that loading the same certificate twice actually does nothing and postfix/dovecot/nginx don't care about the certificate handling/parsing itself, it should (and does!) work flawlessly in my opinion. :-)

@patschi
Copy link
Member

patschi commented Nov 16, 2019

What's the exact state with this PR, @OpenLarry? Now as #2509 was merged in the past, I'd guess that most of the code is outdated and not compatible anymore. Any input from @mhofer117 for this?

@mhofer117
Copy link
Contributor

I had this included in #2509 initially because I thought ECDSA would be merged first. Then removed it so #2509 could be merged. However my changes are still ready here: OpenLarry#1

Personally I have no need for ECDSA certs so i'm not maintaining it, but that PR should solve almost all conflicts

@OpenLarry
Copy link
Contributor Author

I've already merged the mentioned PR by mhofer117 locally and it seems to work. But I wasn't able to test everything yet.

I will try to do that in the next two days and update this PR afterwards. :-)

@OpenLarry
Copy link
Contributor Author

Sorry for the late reply, had a lot of stuff to do during the last days...

I've merged the PR by @mhofer117 containing the ECDSA adjustments for the SNI part and it looks good to me. But I haven't tested the SNI part yet, because I have no need for that. Maybe someone else wants to try that out and verify that everything works properly?

@stale
Copy link

stale bot commented May 20, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions
Copy link

github-actions bot commented Jun 3, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale Please update the issue with current status, unclear if it's still open/needed. label Jun 3, 2021
@mkuron mkuron added enhancement and removed stale Please update the issue with current status, unclear if it's still open/needed. labels Jun 3, 2021
@MAGICCC
Copy link
Member

MAGICCC commented Nov 11, 2021

Just saw your rebase on master, possible to change the base branch to staging and rerebase? :p

@OpenLarry
Copy link
Contributor Author

Sure! I will do that in the coming days and also clean up this branch. :-)

@SecT0uch
Copy link
Contributor

Using ECDSA with last acme.sh deploy hook. Really need that to be merged.

Any news ?

@christianbur
Copy link
Contributor

@SecT0uch
Do you mean this?
I added the ECDSA support over a year ago.

@SecT0uch
Copy link
Contributor

SecT0uch commented Feb 2, 2022

@christianbur
No, I mean mailcow recognizing ecdsa-cert.pem and ecdsa-key.pem intruduced with that commit

I had a previous version of the deploy script that was working well.

Edit: I have mailcow up-to-date and don't want to play with symlinks in docker

@OpenLarry
Copy link
Contributor Author

I've squashed all messy commits together and rebased it on the current staging branch. Seems to work (and is already working for me for years).

@andryyy
Copy link
Contributor

andryyy commented May 31, 2022

Yes, keep in mind there are like 47838374 different setups and thinks will get dirty. We will need to be prepared. Thank you, Aaron! :)

@DerLinkman DerLinkman changed the base branch from master to staging May 31, 2022 18:11
@SecT0uch
Copy link
Contributor

SecT0uch commented Jul 7, 2022

What's the status on that PR ?

@christianbur
Copy link
Contributor

@SecT0uch
Why did you break my acme.sh deploy plugin? -> acmesh-official/acme.sh#4170

If you want to store ECDSA certificates in the (RSA) cert files (cert.pem, key.pem), this would have been possible simply with symlinks. With your change in acme.sh, you destroyed my plugin and also my mail setup, because DANE/TLSA was broken.

@SecT0uch -> Please undo the change as soon as possible.

Create symlink in directory ./mailcow-dockerized/data/assets/ssl

ln -s ecdsa-cert.pem cert.pem
ln -s ecdsa-key.pem key.pem
$ ./mailcow-dockerized/data/assets/ssl# ls -al 
lrwxrwxrwx 1 root root 10 Aug 24 12:11 cert.pem -> ecdsa-cert.pem
lrwxrwx 1 root root 9 Aug 24 12:11 key.pem -> ecdsa-key.pem
-rw-r--r-- 1 root root 5934 Aug 24 11:54 ecdsa-cert.pem
-rw-r--r-- 1 root root 3247 Aug 24 11:54 ecdsa-key.pem

@SecT0uch
Copy link
Contributor

SecT0uch commented Aug 24, 2022

Because you are including custom changes in a public repository that breaks a default mailcow installation.

You broke my installation in the first place with your changes on the acme plugin.
Since clearly this commit won't be merged, I don't see the point in breaking everyone else's installation.

If you want to keep using the custom changes you made on mailcow, you should fork the acme plugin and make your changes on your side.

@DerLinkman
Copy link
Member

Hello everyone,

as i have taken the position to maintain the repository and i'm not 100% sure what your PR does i would kindly ask you to describe what the benefits of ECDSA are and if it will break existing installations.

I've saw, that you've changed also the dovecot.conf for alt_certs. How does dovecot/postfix behave if these certs are not generated?

OpenLarry and others added 2 commits January 24, 2024 19:54
This is a squashed commit of the following:

commit db8051bc234c5fa67aa87a7a94f9e89eaf0e7dac
Merge: 2634fdf 0402068
Author: Aaron Larisch <[email protected]>
Date:   Tue May 24 20:44:38 2022 +0200

    Merge branch 'master' into add-ecdsa-support

commit 2634fdf
Merge: 0962b90 116c791
Author: Aaron Larisch <[email protected]>
Date:   Wed Nov 10 08:53:21 2021 +0100

    Merge branch 'master' into add-ecdsa-support

commit 0962b90
Merge: 6152271 d90d4f9
Author: Aaron Larisch <[email protected]>
Date:   Wed Jun 9 11:33:34 2021 +0200

    Merge branch 'master' into add-ecdsa-support

commit 6152271
Merge: 72261e6 6426476
Author: Aaron Larisch <[email protected]>
Date:   Fri Feb 26 18:20:30 2021 +0100

    Merge branch 'master' into add-ecdsa-support

commit 72261e6
Merge: 3a1cce2 0846013
Author: Aaron Larisch <[email protected]>
Date:   Wed Dec 16 21:33:55 2020 +0100

    Merge branch 'master' into add-ecdsa-support

commit 3a1cce2
Merge: 6a01796 c1034b8
Author: Aaron Larisch <[email protected]>
Date:   Tue Sep 15 10:51:32 2020 +0200

    Merge branch 'master' into add-ecdsa-support

commit 6a01796
Merge: 812adb0 9685b4b
Author: Aaron Larisch <[email protected]>
Date:   Tue Jul 21 14:07:56 2020 +0200

    Merge branch 'master' into add-ecdsa-support

commit 812adb0
Author: Aaron Larisch <[email protected]>
Date:   Sun Jul 5 00:12:21 2020 +0200

    Fix TLSA records for ECDSA and RSA certs in DNS diagnostics

    Disables TLS 1.3 for the test connection to limit to RSA or ECDSA ciphers.

commit 83c9769
Merge: 6fb29ab becc505
Author: Aaron Larisch <[email protected]>
Date:   Sat Jul 4 23:03:45 2020 +0200

    Merge branch 'master' into add-ecdsa-support

commit 6fb29ab
Merge: 3131e17 b933a30
Author: Aaron Larisch <[email protected]>
Date:   Thu May 21 11:34:30 2020 +0200

    Merge branch 'master' into add-ecdsa-support

commit 3131e17
Merge: 1929216 7fa10cc
Author: Aaron Larisch <[email protected]>
Date:   Thu Apr 16 18:20:39 2020 +0200

    Merge branch 'master' into add-ecdsa-support

commit 1929216
Merge: a0edf84 a9947e9
Author: Aaron Larisch <[email protected]>
Date:   Sat Mar 21 08:38:07 2020 +0100

    Merge branch 'master' into add-ecdsa-support

commit a0edf84
Merge: 6152b42 b5c844d
Author: Aaron Larisch <[email protected]>
Date:   Thu Feb 13 13:52:09 2020 +0100

    Merge branch 'master' into add-ecdsa-support

commit 6152b42
Merge: 85b791b e6bb306
Author: Aaron Larisch <[email protected]>
Date:   Wed Jan 15 10:14:18 2020 +0100

    Merge branch 'master' into add-ecdsa-support

commit 85b791b
Merge: c233993 ff74b8a
Author: Aaron Larisch <[email protected]>
Date:   Tue Dec 17 15:21:10 2019 +0100

    Merge branch 'master' into add-ecdsa-support

commit c233993
Merge: eee0238 4e8b2bf
Author: Aaron Larisch <[email protected]>
Date:   Sat Dec 7 17:17:05 2019 +0100

    Merge branch 'master' into add-ecdsa-support

commit eee0238
Merge: 9e1ff33 1d1a9a2
Author: Aaron Larisch <[email protected]>
Date:   Fri Nov 8 12:53:51 2019 +0100

    Merge branch 'master' into add-ecdsa-support

commit 9e1ff33
Merge: ab16425 ea4da60
Author: Aaron Larisch <[email protected]>
Date:   Fri Nov 1 16:06:41 2019 +0100

    Merge branch 'master' into add-ecdsa-support

commit ab16425
Merge: c049926 573e62f
Author: Aaron Larisch <[email protected]>
Date:   Thu Oct 31 13:57:01 2019 +0100

    Merge branch 'master' into add-ecdsa-support

commit c049926
Merge: 6a6d6c4 c431615
Author: Aaron Larisch <[email protected]>
Date:   Thu Oct 31 13:55:28 2019 +0100

    Merge pull request #1 from mhofer117/tls-sni-ecdsa

    Change line endings in functions.inc.php back to CRLF

commit c431615
Author: Marcel Hofer <[email protected]>
Date:   Sun Oct 20 19:02:17 2019 +0200

    remove empty docker-entrypoint.sh

commit efd6cd1
Merge: a2a0821 6a6d6c4
Author: Marcel Hofer <[email protected]>
Date:   Sun Oct 20 19:00:07 2019 +0200

    Merge remote-tracking branch 'OpenLarry/add-ecdsa-support' into tls-sni-ecdsa

    # Conflicts:
    #	data/Dockerfiles/acme/docker-entrypoint.sh
    #	data/conf/dovecot/dovecot.conf
    #	data/conf/nginx/site.conf
    #	data/conf/postfix/main.cf
    #	data/web/inc/ajax/dns_diagnostics.php
    #	data/web/inc/functions.inc.php
    #	docker-compose.yml
    #	generate_config.sh
    #	update.sh

commit a2a0821
Merge: 4a62809 05e7c95
Author: Marcel Hofer <[email protected]>
Date:   Sun Oct 20 18:50:16 2019 +0200

    Merge branch 'tls-sni' into tls-sni-ecdsa

commit 4a62809
Author: Marcel Hofer <[email protected]>
Date:   Sat Oct 19 13:04:02 2019 +0200

    [SSL] add optional ecdsa certs in addition to rsa certs

commit 6a6d6c4
Merge: 351abd2 9f66b83
Author: Aaron Larisch <[email protected]>
Date:   Tue Oct 1 11:01:28 2019 +0200

    Merge branch 'master' into add-ecdsa-support

commit 351abd2
Merge: eddb269 0485379
Author: Aaron Larisch <[email protected]>
Date:   Mon Sep 9 17:40:47 2019 +0200

    Merge branch 'master' into add-ecdsa-support

commit eddb269
Merge: 9d13ead 6e82a35
Author: Aaron Larisch <[email protected]>
Date:   Thu Aug 29 11:36:03 2019 +0200

    Merge branch 'master' into add-ecdsa-support

commit 9d13ead
Merge: 478c4d1 f21cf13
Author: Aaron Larisch <[email protected]>
Date:   Thu Aug 8 13:22:58 2019 +0200

    Merge branch 'master' into add-ecdsa-support

commit 478c4d1
Merge: 46dbf3b 7665cc2
Author: Aaron Larisch <[email protected]>
Date:   Thu Jun 27 14:49:09 2019 +0200

    Merge branch 'master' into add-ecdsa-support

commit 46dbf3b
Merge: 680a272 69fb7f7
Author: Aaron Larisch <[email protected]>
Date:   Fri May 31 12:33:32 2019 +0200

    Merge branch 'master' into add-ecdsa-support

commit 680a272
Merge: f69559f b20ff13
Author: Aaron Larisch <[email protected]>
Date:   Tue May 7 12:29:34 2019 +0200

    Merge branch 'master' into add-ecdsa-support

commit f69559f
Merge: 3e8a958 cd88165
Author: Aaron Larisch <[email protected]>
Date:   Mon Apr 15 12:55:41 2019 +0200

    Merge branch 'master' into add-ecdsa-support

commit 3e8a958
Merge: 956a487 4aae727
Author: Aaron <[email protected]>
Date:   Mon Mar 18 16:52:37 2019 +0100

    Merge branch 'master' into add-ecdsa-support

commit 956a487
Author: Aaron Larisch <[email protected]>
Date:   Sun Mar 17 12:34:56 2019 +0100

    Set SKIP_ECDSA_CERT to y by default

commit 7103fe7
Author: Aaron Larisch <[email protected]>
Date:   Sun Mar 17 11:05:05 2019 +0100

    Add SKIP_ECDSA_CERT config parameter

commit 91fca4f
Author: Aaron Larisch <[email protected]>
Date:   Sat Mar 16 18:48:28 2019 +0100

    Show TLSA records for ECDSA certificates in DNS diagnostics

commit cc521b0
Author: Aaron Larisch <[email protected]>
Date:   Sat Mar 16 13:04:03 2019 +0100

    Add ECDSA support

Co-authored-by: Marcel Hofer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ECDSA certificates
10 participants