gpt4 book ai didi

ssl - 服务器中的 "ssl3_get_client_hello:no shared cipher"取决于服务器证书和 key

转载 作者:太空宇宙 更新时间:2023-11-03 13:15:41 25 4
gpt4 key购买 nike

我正在使用 openssl 对客户端和服务器进行测试。在我的测试中,服务器根据参数 mode 使用一对(证书、 key )或其他。

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(我的) key 签名的。

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

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

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

提前感谢您的任何回复。

最佳答案

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

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

关于ssl - 服务器中的 "ssl3_get_client_hello:no shared cipher"取决于服务器证书和 key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40292951/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com