"ssl3_get_client_hello:no shared cipher" 在服务器中取决于服务器证书和密钥

"ssl3_get_client_hello:no shared cipher" in server depending on server certificate and key

我正在 运行 使用 openssl 对客户端和服务器进行测试。在我的测试中,服务器根据参数 mode.

使用一对(证书,密钥)或其他
void configure_context(SSL_CTX *ctx, int mode)
{
    if (mode == 0) {
        /* Set the key and cert */
        if (SSL_CTX_use_certificate_file(ctx, "./test/certs/testcert2.pem", SSL_FILETYPE_PEM) < 0) {
            ERR_print_errors_fp(stderr);
            exit(EXIT_FAILURE);
        }

        if (SSL_CTX_use_PrivateKey_file(ctx, "test2.key", SSL_FILETYPE_PEM) < 0 ) {
            ERR_print_errors_fp(stderr);
            exit(EXIT_FAILURE);
        }
    } else {
        if (SSL_CTX_use_certificate_file(ctx, "cert.pem", SSL_FILETYPE_PEM) < 0) {
            ERR_print_errors_fp(stderr);
            exit(EXIT_FAILURE);
        }

        if (SSL_CTX_use_PrivateKey_file(ctx, "key.pem", SSL_FILETYPE_PEM) < 0 ) {
            ERR_print_errors_fp(stderr);
            exit(EXIT_FAILURE);
        }
    }
}

cert.pem 是一个自签名证书,而 testcert2 是用 CA(我的)密钥签名的。

当我使用 cert.pem 时,一切正常,服务器选择密码 TLS_RSA_WITH_AES_128_GCM_SHA256

当我使用 testcert2 时,服务器出现错误 "ssl3_get_client_hello:no shared cipher"。

  1. 服务器中选择的密码是否依赖于证书和密钥?
  2. 这个错误可能是由于与密钥无关的原因造成的吗?
  3. 如何查看某个密钥可以支持的密码?

提前感谢您的回复。

密码的选择部分取决于证书,即具有 RSA 身份验证的密码需要 RSA 证书,具有 ECDSA 身份验证的密码需要 ECDSA 证书等。

但另一种可能是您加载的密钥和证书不匹配。在这种情况下,不能使用证书,只能使用匿名身份验证的密码。当您的代码加载证书时,它不会检查密钥是否适合证书:为此使用 SSL_CTX_check_private_key