跳到主要内容
ecdsa.com
OpenSSL (server side: nginx, Apache, Postfix, openssl s_server)OpenSSL CLI

错误信息

SSL routines:tls_post_process_client_hello:no shared cipher

也可能输出为

  • SSL_do_handshake() failed (SSL: error:0A0000C1:SSL routines::no shared cipher)
  • error:0A0000C1:SSL routines::no shared cipher

openssl s_server(OpenSSL 3.x)记录的是“error:0A0000C1:SSL routines:tls_post_process_client_hello:no shared cipher:<source>”;nginx 以 info 级别记录“SSL_do_handshake() failed (SSL: error:0A0000C1:SSL routines::no shared cipher) while SSL handshaking”,因此在默认的 error_log 级别下看不到。OpenSSL 1.1.1 使用的代码是 1417A0C1。

OpenSSL (server side: nginx, Apache, Postfix, openssl s_server) — SSL_R_NO_SHARED_CIPHER

含义

这是服务器视角下的握手失败:客户端 ClientHello 中的密码套件,没有一个既在服务器上启用、又能与服务器证书的密钥配合使用。随后服务器向客户端发送 handshake_failure(告警 40)。这条错误出现在服务器日志中,而不是客户端输出中。

原因

修复方法

  1. 1.

    对照套件检查证书密钥

    ECDHE-ECDSA-* 套件需要 ECDSA 证书,ECDHE-RSA-* 套件需要 RSA 证书;同时拥有两种证书的服务器可以列出两类套件。

    bash
    # ECDSA key + only ECDHE-RSA suites (or the reverse) leaves nothing usable
    openssl x509 -in server.pem -noout -text | grep 'Public Key Algorithm'
    openssl ciphers -v 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256'
  2. 2.

    列出服务器实际接受的套件

    从外部逐一枚举,再与需要支持的客户端对照。

    bash
    # Which TLS 1.2 suites does the server accept? (nmap needed)
    nmap --script ssl-enum-ciphers -p 443 api.example.com
  3. 3.

    使用经过充分测试的套件列表

    从生成的现代配置或中间配置出发,而不要手动精简列表。

    text
    # nginx: suites for both RSA and ECDSA certificates, TLS 1.3 enabled
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers 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;

相关错误

浏览完整的签名错误库