AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1151325
Accepted
Esa Jokinen
Esa Jokinen
Asked: 2024-01-12 01:15:52 +0800 CST2024-01-12 01:15:52 +0800 CST 2024-01-12 01:15:52 +0800 CST

如何从 Let's Encrypt for Postfix 获取 ECC 和 RSA 证书?

  • 772

自 Certbot 2.0 起, Let's Encrypt 已开始默认颁发 ECC 证书。对于现代 Web 浏览器来说这不是问题,但 Let's Encrypt 证书也可以用于 HTTPS 之外的其他用途。即,某些 SMTP 服务器尚不支持 ECC 证书。STARTTLS如果此类服务器尝试与使用 ECC 证书的 Postfix建立连接,则会失败。

日志表明不存在共享密码,尽管 Wireshark 显示 TLS 握手中的客户端 Hello 显然具有通过配置的列表的公共密码smtpd_tls_mandatory_ciphers = medium。

postfix/smtpd[1337]: connect from mail.example.net[198.51.100.1]
postfix/smtpd[1337]: SSL_accept error from mail.example.net[198.51.100.1]: -1
postfix/smtpd[1337]: warning: TLS library problem: error:0A0000C1:SSL routines::no shared cipher:../ssl/statem/statem_srvr.c:2220:
postfix/smtpd[1337]: lost connection after STARTTLS from mail.example.net[198.51.100.1]
postfix/smtpd[1337]: disconnect from mail.example.net[198.51.100.1] ehlo=1 starttls=0/1 commands=1/2

该问题是由证书类型引起的。是否可以使用 Certbot 从 Let's Encrypt 获取 ECC 和 RSA 证书?如何配置 Postfix 同时使用它们?

ssl
  • 1 1 个回答
  • 54 Views

1 个回答

  • Voted
  1. Best Answer
    Esa Jokinen
    2024-01-12T01:15:52+08:002024-01-12T01:15:52+08:00

    来自 Let's Encrypt (Certbot) 的附加 RSA 证书

    有一些解决方案的答案需要自定义脚本。该解决方案完全依赖于 Certbot 配置。做出以下假设。如果您的设置有所不同,请根据您的需要更改说明。

    • 有一个 ECC 证书配置为mail.example.com使用它作为证书名称 ( --cert-name);更新配置/etc/letsencrypt/renewal/mail.example.com.conf等。

    • Certbot 的默认设置是通过配置文件 /etc/letsencrypt/cli.ini配置的。此示例使用具有更强secp384r1曲线(默认secp256r1)和增加的 RSA 密钥大小4096(默认2048)的 ECC 证书以及预配置的身份验证器:

      # Because we are using logrotate for greater flexibility, disable the
      # internal certbot logrotation.
      max-log-backups = 0
      
      # Use ECC for the private key
      key-type = ecdsa
      elliptic-curve = secp384r1
      
      # Use a 4096 bit RSA key instead of 2048
      rsa-key-size = 4096
      
      # Use webroot authenticator; common webroot for all sites
      authenticator = webroot
      webroot-path = /var/www/letsencrypt
      

    您可以cli.ini使用 RSA 密钥类型复制文件:

    sed -E 's/key-type.?=.?ecdsa/key-type = rsa/' /etc/letsencrypt/cli.ini \
      | sed 's/^# Use ECC/# Use RSA/' \
      | sudo tee /etc/letsencrypt/cli-rsa.ini
    

    关键设置是key-type = rsa. 复制该文件,以便不会更改所有新证书的默认配置。在此示例中,该命令创建cli-rsa.ini具有:

    # Because we are using logrotate for greater flexibility, disable the
    # internal certbot logrotation.
    max-log-backups = 0
    
    # Use RSA for the private key
    key-type = rsa
    elliptic-curve = secp384r1
    
    # Use a 4096 bit RSA key instead of 2048
    rsa-key-size = 4096
    
    # Use webroot authenticator; common webroot for all sites
    authenticator = webroot
    webroot-path = /var/www/letsencrypt
    

    您可以使用配置文件为mail.example.com. 该--cert-name证书必须与 ECC 证书不同,因为我们请求额外的 RSA 证书而不是替换当前证书。例如,

    sudo certbot certonly \
      --cert-name mail.example.com-rsa \
      -d mail.example.com \
      -c /etc/letsencrypt/cli-rsa.ini
    

    如果您的续订方法配置正确,您应该得到:

    Requesting a certificate for mail.example.com
    
    Successfully received certificate.
    Certificate is saved at: /etc/letsencrypt/live/mail.example.com-rsa/fullchain.pem
    Key is saved at:         /etc/letsencrypt/live/mail.example.com-rsa/privkey.pem
    

    您将在 Postfix 配置中需要这些路径。

    Postfix 中的多个证书

    借助Postfix TLS 支持,您可以同时配置多个证书。自 Postfix 3.4 起,建议使用该smtpd_tls_chain_files参数(而不是传统的smtpd_tls_cert_file&smtpd_tls_key_file用于 RSA & smtpd_tls_eccert_file&smtpd_tls_eckey_file用于 ECDSA)。

    值得注意的是:

    您还可以将密钥与其证书分开存储,前提是每个密钥都列在相应的证书链之前。不建议将密钥及其关联的证书链存储在单独的文件中,因为这在密钥滚动期间很容易出现竞争条件,因为无法自动更新多个文件。

    然而,

    • Certbot 将密钥和链存储在单独的文件中。
    • 您可以使用在成功续订时--deploy-hook运行的脚本来配置。systemctl reload postfix

    的配置示例main.cf;注意正确的顺序:每个证书链之前的每个私钥:

    smtpd_tls_chain_files =
        /etc/letsencrypt/live/mail.example.com/privkey.pem,
        /etc/letsencrypt/live/mail.example.com/fullchain.pem,
        /etc/letsencrypt/live/mail.example.com-rsa/privkey.pem,
        /etc/letsencrypt/live/mail.example.com-rsa/fullchain.pem
    
    • 0

相关问题

  • 如何使用 Tomcat 5.5 更新 SSL 证书

  • 为 IIS6 自行生成 SSL 证书?

  • plesk 上的域和子域 ssl 访问

  • 如何设置 SSL 邮件服务器?

  • 如何通过 SVN 命令行接受 SSL 证书?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve