本文介绍了“ssl3_get_client_hello:没有共享密码";在服务器中取决于服务器证书和密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 openssl 对客户端和服务器进行测试.在我的测试中,服务器使用一对(证书、密钥)或其他基于参数mode.

I'm running a test with client and server using openssl. In my test, the server uses one pair (certificate, key) or other based on a parameter 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 is a self-signed certificate while testcert2 is signed with a CA (mine) key.

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

When I use cert.pem, everything works well and the server selects cipher TLS_RSA_WITH_AES_128_GCM_SHA256

当我使用 testcert2 时,我在服务器中收到错误ssl3_get_client_hello:no shared cipher".

When I use testcert2, I get error "ssl3_get_client_hello:no shared cipher" in the server.

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

提前感谢您的回复.

推荐答案

密码的选择部分取决于证书,即采用 RSA 认证的密码需要 RSA 证书,采用 ECDSA 认证的密码需要 ECDSA 证书等.

The choice of ciphers depends in part on the certificates, i.e. ciphers with RSA authentication need an RSA certificate, ciphers with ECDSA authentication an ECDSA certificate etc.

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

But another possibility is that the key and the certificate you load do not match each other. In this case no certificate can be used and it can only use ciphers with anonymous authentication. While your code loads the certificates it does not check if the key fits the certificate: use SSL_CTX_check_private_key for this.

这篇关于“ssl3_get_client_hello:没有共享密码";在服务器中取决于服务器证书和密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 07:44