You need to sign in or sign up before continuing.
提交 dc87d5a9 编写于 作者: M Matt Caswell

Tweak the client side PSK callback

Ensure that we properly distinguish between successful return (PSK
provided), successful return (no PSK provided) and failure.
Reviewed-by: NRich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3670)
上级 801d9fbd
...@@ -203,6 +203,9 @@ static int psk_use_session_cb(SSL *s, const EVP_MD *md, ...@@ -203,6 +203,9 @@ static int psk_use_session_cb(SSL *s, const EVP_MD *md,
if (cipher == NULL) { if (cipher == NULL) {
/* Doesn't look like a suitable TLSv1.3 key. Ignore it */ /* Doesn't look like a suitable TLSv1.3 key. Ignore it */
OPENSSL_free(key); OPENSSL_free(key);
*id = NULL;
*idlen = 0;
*sess = NULL;
return 0; return 0;
} }
usesess = SSL_SESSION_new(); usesess = SSL_SESSION_new();
...@@ -221,13 +224,17 @@ static int psk_use_session_cb(SSL *s, const EVP_MD *md, ...@@ -221,13 +224,17 @@ static int psk_use_session_cb(SSL *s, const EVP_MD *md,
if (cipher == NULL) if (cipher == NULL)
goto err; goto err;
if (md != NULL && SSL_CIPHER_get_handshake_digest(cipher) != md) if (md != NULL && SSL_CIPHER_get_handshake_digest(cipher) != md) {
goto err; /* PSK not usable, ignore it */
*id = NULL;
*idlen = 0;
*sess = NULL;
SSL_SESSION_free(usesess);
} else {
*sess = usesess; *sess = usesess;
*id = (unsigned char *)psk_identity; *id = (unsigned char *)psk_identity;
*idlen = strlen(psk_identity); *idlen = strlen(psk_identity);
}
return 1; return 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册