# How to Generate a Strong, Unique Diffie Hellman Group

**URL:** <https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624>\
**Category:** Help\
**Created:** [July 4, 2022, 9:35am UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624 "2022-07-04T09:35:42Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjaone](https://avatars.discourse-cdn.com/v4/letter/b/d9b06d/32.png) [@benjaone](https://community.letsencrypt.org/u/benjaone)\
**Post date:** [July 4, 2022, 9:35am UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624/1 "2022-07-04T09:35:42Z")

</div>

Hi,

I have a LAMP stack Digital Ocean Droplet with multiple virtual hosts.

I try to generate and use 2048-bit or stronger Diffie-Hellman groups.

I already added the key with this code:

`openssl dhparam -out dhparams.pem 2048`

Now I try to use the new 2048-bit groups by using this code:

`cat /path/to/custom/dhparam >> /path/to/sslcertfile`

I tried:

`cat /etc/letsencrypt/live/www.mydomain.net/privkey.pem >> /etc/letsencrypt/live/www.mydomain/fullchain.pem`

Without luck.

I also tried:

`SSLOpenSSLConfCmd DHParameters "/path/to/dhparams.pem"`

And got: SSLOpenSSLConfCmd: command not found

Any idea on how to fix this?

Thanks

Ben

---

<div class="post-metadata">

**Author:** ![Osiris](https://avatars.discourse-cdn.com/v4/letter/o/839c29/32.png) [@Osiris](https://community.letsencrypt.org/u/Osiris)\
**Post date:** [July 4, 2022, 9:44am UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624/2 "2022-07-04T09:44:59Z")

</div>

Why not use (one of) the named finite field groups as recommended by Mozilla? See the intermediate configuration at [Security/Server Side TLS - MozillaWiki](https://wiki.mozilla.org/Security/Server_Side_TLS) and the corresponding RFC.

May I also suggest the Mozilla SSL configuration generator at [https://ssl-config.mozilla.org/](https://ssl-config.mozilla.org/)? This includes instructions for the inclusion of the ffdhe2048 parameters.

Or even better: just remove all classic DH ciphers from your cipher suit list.. 😛 Unless you absolutely require these due to client compatibility.

---

<div class="post-metadata">

**Author:** ![benjaone](https://avatars.discourse-cdn.com/v4/letter/b/d9b06d/32.png) [@benjaone](https://community.letsencrypt.org/u/benjaone)\
**Post date:** [July 4, 2022, 9:52am UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624/3 "2022-07-04T09:52:05Z")

</div>

Hi Osiris,

I love the last suggestion since it seems to be much easier 😃

This is my suit list:

`SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA`

How do I know which to remove?

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![benjaone](https://avatars.discourse-cdn.com/v4/letter/b/d9b06d/32.png) [@benjaone](https://community.letsencrypt.org/u/benjaone)\
**Post date:** [July 4, 2022, 10:16am UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624/4 "2022-07-04T10:16:13Z")

</div>

I changed to the cipher suit from Firefox:

```nohighlight
ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384

```

Which works great.

I still want to use 2048-bit Diffie Hellman Group and seek help to do so, thanks!

---

<div class="post-metadata">

**Author:** ![Osiris](https://avatars.discourse-cdn.com/v4/letter/o/839c29/32.png) [@Osiris](https://community.letsencrypt.org/u/Osiris)\
**Post date:** [July 4, 2022, 10:34am UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624/5 "2022-07-04T10:34:42Z")

</div>

> [@benjaone](#):
>
> I still want to use 2048-bit Diffie Hellman Group

~~I don't understand. Why would you still want to use classic DH groups without classic DH cipher suits? It's either both or neither.~~

Edit: Although I see you haven't actually removed the classic DH cipher suits, so I guess you don't want to exclude them totally.

> [@benjaone](#):
>
> I still want to use 2048-bit Diffie Hellman Group and seek help to do so, thanks!

The Mozilla SSL generator should provide enough info.

---

<div class="post-metadata">

**Author:** ![benjaone](https://avatars.discourse-cdn.com/v4/letter/b/d9b06d/32.png) [@benjaone](https://community.letsencrypt.org/u/benjaone)\
**Post date:** [July 4, 2022, 10:37am UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624/6 "2022-07-04T10:37:41Z")

</div>

Please take a look at Key Exchange Parameters:

> **[Website test: www.a-c-d.net](https://en.xn--sikkerpnettet-vfb.dk/site/www.a-c-d.net/89344/#)**
>
> Test for modern Internet Standards like IPv6, DNSSEC, HTTPS, TLS, HSTS, 
> DMARC, DKIM, SPF, STARTTLS and DANE.

---

<div class="post-metadata">

**Author:** ![benjaone](https://avatars.discourse-cdn.com/v4/letter/b/d9b06d/32.png) [@benjaone](https://community.letsencrypt.org/u/benjaone)\
**Post date:** [July 4, 2022, 10:41am UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624/7 "2022-07-04T10:41:41Z")

</div>

I tried to, its a mistake, thanks for letting me know. I don't know how to do so 😃

---

<div class="post-metadata">

**Author:** ![benjaone](https://avatars.discourse-cdn.com/v4/letter/b/d9b06d/32.png) [@benjaone](https://community.letsencrypt.org/u/benjaone)\
**Post date:** [July 14, 2022, 5:35pm UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624/8 "2022-07-14T17:35:24Z")

</div>

Thanks.

What are the correct paths?

SSLCertificateFile /path/to/signed\_cert\_and\_intermediate\_certs\_and\_dhparams  
SSLCertificateKeyFile /path/to/private\_key  
/path/to/sslcertfile

These seems to be wrong:

/etc/letsencrypt/live/www.mydomain.net/privkey.pem  
/etc/letsencrypt/live/www.mydomain/fullchain.pem

---

<div class="post-metadata">

**Author:** ![Osiris](https://avatars.discourse-cdn.com/v4/letter/o/839c29/32.png) [@Osiris](https://community.letsencrypt.org/u/Osiris)\
**Post date:** [July 14, 2022, 5:52pm UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624/9 "2022-07-14T17:52:39Z")

</div>

`privkey.pem` and `fullchain.pem` _can_ be used for `SSLCertificateKeyFile` and `SSLCertificateFile` respectively, but that would lack your DH params. Certbot does not offer those. However, you could e.g. save [https://ssl-config.mozilla.org/ffdhe2048.txt](https://ssl-config.mozilla.org/ffdhe2048.txt) to `/etc/letsencrypt/ffdhe2048.txt` and use that file to concatenate to `fullchain.pem`. I suggest to use a script to do that and use that script in the `--deploy-hook` command of Certbot.

---

<div class="post-metadata">

**Author:** ![benjaone](https://avatars.discourse-cdn.com/v4/letter/b/d9b06d/32.png) [@benjaone](https://community.letsencrypt.org/u/benjaone)\
**Post date:** [July 14, 2022, 6:17pm UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624/10 "2022-07-14T18:17:31Z")

</div>

Sounds good.

Do you know a link to an example or such where such a script is used in --deploy-hook command?

Thanks again, I really appreciate it!

---

<div class="post-metadata">

**Author:** ![rg305](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/rg305/32/91314_2.png) [@rg305](https://community.letsencrypt.org/u/rg305)\
**Post date:** [July 14, 2022, 6:17pm UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624/11 "2022-07-14T18:17:33Z")

</div>

Try using:  
`SSLOpenSSLConfCmd DHParameters /path/to/dhparams.pem`

[presuming you are using `Apache`]

---

<div class="post-metadata">

**Author:** ![Osiris](https://avatars.discourse-cdn.com/v4/letter/o/839c29/32.png) [@Osiris](https://community.letsencrypt.org/u/Osiris)\
**Post date:** [July 14, 2022, 6:19pm UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624/12 "2022-07-14T18:19:46Z")

</div>

> [@rg305](#):
>
> Try using:  
> `SSLOpenSSLConfCmd DHParameters /path/to/dhparams.pem`

See OP:

> [@benjaone](#):
>
> I also tried:
> 
> `SSLOpenSSLConfCmd DHParameters "/path/to/dhparams.pem"`
> 
> And got: SSLOpenSSLConfCmd: command not found

😉

Although reading that error I'm not sure it was actually used in an Apache configuration file or just plain on the command line?

I'm sure OP currently has enough info to combine that Apache configuration command with the `ffdhe2048.txt` from Mozillas site.

---

<div class="post-metadata">

**Author:** ![rg305](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/rg305/32/91314_2.png) [@rg305](https://community.letsencrypt.org/u/rg305)\
**Post date:** [July 14, 2022, 6:26pm UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624/13 "2022-07-14T18:26:39Z")

</div>

> [@benjaone](#):
>
> I also tried:

Silly me.

**What version of OpenSSL are you using?**

---

<div class="post-metadata">

**Author:** ![benjaone](https://avatars.discourse-cdn.com/v4/letter/b/d9b06d/32.png) [@benjaone](https://community.letsencrypt.org/u/benjaone)\
**Post date:** [July 14, 2022, 6:28pm UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624/14 "2022-07-14T18:28:25Z")

</div>

Thanks!

I just created the /etc/letsencrypt/ffdhe2048.txt

and pasted this in it:

```nohighlight

-----BEGIN DH PARAMETERS-----
MIIBCAKCAQEA//////////+t+FRYortKmq/cViAnPTzx2LnFg84tNpWp4TZBFGQz
+8yTnc4kmz75fS/jY2MMddj2gbICrsRhetPfHtXV/WVhJDP1H18GbtCFY2VVPe0a
87VXE15/V8k1mE8McODmi3fipona8+/och3xWKE2rec1MKzKT0g6eXq8CrGCsyT7
YdEIqUuyyOP7uWrat2DX9GgdT0Kj3jlN9K5W7edjcrsZCwenyO4KbXCeAvzhzffi
7MA0BM0oNC9hkXL+nOmFg/+OTxIy7vKBg8P+OxtMb61zO7X8vC7CIAXFjvGDfRaD
ssbzSibBsu/6iGtCOGEoXJf//////////wIBAg==
-----END DH PARAMETERS-----

```

The I tried this:

SSLOpenSSLConfCmd DHParameters /etc/letsencrypt/live/www.a-c-d.net/privkey.pem

and got: SSLOpenSSLConfCmd: command not found

What am I missing?

And yes, I have a LAMP stack.

Thanks!

---

<div class="post-metadata">

**Author:** ![benjaone](https://avatars.discourse-cdn.com/v4/letter/b/d9b06d/32.png) [@benjaone](https://community.letsencrypt.org/u/benjaone)\
**Post date:** [July 14, 2022, 6:29pm UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624/15 "2022-07-14T18:29:38Z")

</div>

OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)

Thanks!

---

<div class="post-metadata">

**Author:** ![Osiris](https://avatars.discourse-cdn.com/v4/letter/o/839c29/32.png) [@Osiris](https://community.letsencrypt.org/u/Osiris)\
**Post date:** [July 14, 2022, 6:32pm UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624/16 "2022-07-14T18:32:07Z")

</div>

> [@benjaone](#):
>
> The I tried this:
> 
> SSLOpenSSLConfCmd DHParameters /etc/letsencrypt/live/www.a-c-d.net/privkey.pem
> 
> and got: SSLOpenSSLConfCmd: command not found

Two things:

- What do you mean with "I tried"? Did you just type that in the command line? Or at the appropriate place in an Apache configuration file?
- Why are you using `privkey.pem` as the option for the `DHParameters`? That doesn't make much (read: any) sense. The `DHParameters` option for `SSLOpenSSLConfCmd` expects, well... DH parameters.. And you've just pasted them into `/etc/letsencrypt/ffdhe2048.txt`.

---

<div class="post-metadata">

**Author:** ![benjaone](https://avatars.discourse-cdn.com/v4/letter/b/d9b06d/32.png) [@benjaone](https://community.letsencrypt.org/u/benjaone)\
**Post date:** [July 14, 2022, 6:32pm UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624/17 "2022-07-14T18:32:26Z")

</div>

> [@benjaone](#):
>
> /path/to/dhparams.pem

I am in doubt if `/path/to/dhparams.pem` is

`/etc/letsencrypt/live/www.a-c-d.net/privkey.pem`

Thanks!

---

<div class="post-metadata">

**Author:** ![rg305](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/rg305/32/91314_2.png) [@rg305](https://community.letsencrypt.org/u/rg305)\
**Post date:** [July 14, 2022, 6:35pm UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624/18 "2022-07-14T18:35:42Z")

</div>

> [@benjaone](#):
>
> The I tried this:
> 
> `SSLOpenSSLConfCmd DHParameters /etc/letsencrypt/live/www.a-c-d.net/privkey.pem`

That should be:  
`SSLOpenSSLConfCmd DHParameters /etc/letsencrypt/ffdhe2048.txt`

---

<div class="post-metadata">

**Author:** ![benjaone](https://avatars.discourse-cdn.com/v4/letter/b/d9b06d/32.png) [@benjaone](https://community.letsencrypt.org/u/benjaone)\
**Post date:** [July 14, 2022, 6:35pm UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624/19 "2022-07-14T18:35:47Z")

</div>

Yea, I am new to this and is in deep water. Yes I just typed it in the command line.

I could really need a good tutorial on this 😃

---

<div class="post-metadata">

**Author:** ![benjaone](https://avatars.discourse-cdn.com/v4/letter/b/d9b06d/32.png) [@benjaone](https://community.letsencrypt.org/u/benjaone)\
**Post date:** [July 14, 2022, 6:36pm UTC](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624/20 "2022-07-14T18:36:24Z")

</div>

> [@rg305](#):
>
> SSLOpenSSLConfCmd DHParameters /etc/letsencrypt/ffdhe2048.txt

Ahhhh 😃

[Next page](https://community.letsencrypt.org/t/how-to-generate-a-strong-unique-diffie-hellman-group/180624.md?page=2)
