提交 bb1aaab4 编写于 作者: M Matt Caswell

Fix error when server does not send CertificateStatus message

If a server sends the status_request extension then it may choose
to send the CertificateStatus message. However this is optional.
We were treating it as mandatory and the connection was failing.

Thanks to BoringSSL for reporting this issue.

RT#4120
Reviewed-by: NViktor Dukhovni <viktor@openssl.org>
上级 ef96e4a2
...@@ -303,13 +303,14 @@ int ossl_statem_client_read_transition(SSL *s, int mt) ...@@ -303,13 +303,14 @@ int ossl_statem_client_read_transition(SSL *s, int mt)
break; break;
case TLS_ST_CR_CERT: case TLS_ST_CR_CERT:
if (s->tlsext_status_expected) { /*
if (mt == SSL3_MT_CERTIFICATE_STATUS) { * The CertificateStatus message is optional even if
* |tlsext_status_expected| is set
*/
if (s->tlsext_status_expected && mt == SSL3_MT_CERTIFICATE_STATUS) {
st->hand_state = TLS_ST_CR_CERT_STATUS; st->hand_state = TLS_ST_CR_CERT_STATUS;
return 1; return 1;
} }
return 0;
}
/* Fall through */ /* Fall through */
case TLS_ST_CR_CERT_STATUS: case TLS_ST_CR_CERT_STATUS:
...@@ -2155,7 +2156,6 @@ MSG_PROCESS_RETURN tls_process_cert_status(SSL *s, PACKET *pkt) ...@@ -2155,7 +2156,6 @@ MSG_PROCESS_RETURN tls_process_cert_status(SSL *s, PACKET *pkt)
SSLerr(SSL_F_TLS_PROCESS_CERT_STATUS, SSL_R_LENGTH_MISMATCH); SSLerr(SSL_F_TLS_PROCESS_CERT_STATUS, SSL_R_LENGTH_MISMATCH);
goto f_err; goto f_err;
} }
OPENSSL_free(s->tlsext_ocsp_resp);
s->tlsext_ocsp_resp = OPENSSL_malloc(resplen); s->tlsext_ocsp_resp = OPENSSL_malloc(resplen);
if (s->tlsext_ocsp_resp == NULL) { if (s->tlsext_ocsp_resp == NULL) {
al = SSL_AD_INTERNAL_ERROR; al = SSL_AD_INTERNAL_ERROR;
...@@ -2168,20 +2168,6 @@ MSG_PROCESS_RETURN tls_process_cert_status(SSL *s, PACKET *pkt) ...@@ -2168,20 +2168,6 @@ MSG_PROCESS_RETURN tls_process_cert_status(SSL *s, PACKET *pkt)
goto f_err; goto f_err;
} }
s->tlsext_ocsp_resplen = resplen; s->tlsext_ocsp_resplen = resplen;
if (s->ctx->tlsext_status_cb) {
int ret;
ret = s->ctx->tlsext_status_cb(s, s->ctx->tlsext_status_arg);
if (ret == 0) {
al = SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE;
SSLerr(SSL_F_TLS_PROCESS_CERT_STATUS, SSL_R_INVALID_STATUS_RESPONSE);
goto f_err;
}
if (ret < 0) {
al = SSL_AD_INTERNAL_ERROR;
SSLerr(SSL_F_TLS_PROCESS_CERT_STATUS, ERR_R_MALLOC_FAILURE);
goto f_err;
}
}
return MSG_PROCESS_CONTINUE_READING; return MSG_PROCESS_CONTINUE_READING;
f_err: f_err:
ssl3_send_alert(s, SSL3_AL_FATAL, al); ssl3_send_alert(s, SSL3_AL_FATAL, al);
...@@ -2220,6 +2206,28 @@ MSG_PROCESS_RETURN tls_process_server_done(SSL *s, PACKET *pkt) ...@@ -2220,6 +2206,28 @@ MSG_PROCESS_RETURN tls_process_server_done(SSL *s, PACKET *pkt)
return MSG_PROCESS_ERROR; return MSG_PROCESS_ERROR;
} }
/*
* Call the ocsp status callback if needed. The |tlsext_ocsp_resp| and
* |tlsext_ocsp_resplen| values will be set if we actually received a status
* message, or NULL and -1 otherwise
*/
if (s->tlsext_status_expected && s->ctx->tlsext_status_cb != NULL) {
int ret;
ret = s->ctx->tlsext_status_cb(s, s->ctx->tlsext_status_arg);
if (ret == 0) {
ssl3_send_alert(s, SSL3_AL_FATAL,
SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE);
SSLerr(SSL_F_TLS_PROCESS_SERVER_DONE,
SSL_R_INVALID_STATUS_RESPONSE);
return MSG_PROCESS_ERROR;
}
if (ret < 0) {
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
SSLerr(SSL_F_TLS_PROCESS_SERVER_DONE, ERR_R_MALLOC_FAILURE);
return MSG_PROCESS_ERROR;
}
}
#ifndef OPENSSL_NO_SCTP #ifndef OPENSSL_NO_SCTP
/* Only applies to renegotiation */ /* Only applies to renegotiation */
if (SSL_IS_DTLS(s) && BIO_dgram_is_sctp(SSL_get_wbio(s)) if (SSL_IS_DTLS(s) && BIO_dgram_is_sctp(SSL_get_wbio(s))
......
...@@ -2847,6 +2847,9 @@ int ssl_check_serverhello_tlsext(SSL *s) ...@@ -2847,6 +2847,9 @@ int ssl_check_serverhello_tlsext(SSL *s)
s-> s->
initial_ctx->tlsext_servername_arg); initial_ctx->tlsext_servername_arg);
OPENSSL_free(s->tlsext_ocsp_resp);
s->tlsext_ocsp_resp = NULL;
s->tlsext_ocsp_resplen = -1;
/* /*
* If we've requested certificate status and we wont get one tell the * If we've requested certificate status and we wont get one tell the
* callback * callback
...@@ -2855,12 +2858,9 @@ int ssl_check_serverhello_tlsext(SSL *s) ...@@ -2855,12 +2858,9 @@ int ssl_check_serverhello_tlsext(SSL *s)
&& s->ctx && s->ctx->tlsext_status_cb) { && s->ctx && s->ctx->tlsext_status_cb) {
int r; int r;
/* /*
* Set resp to NULL, resplen to -1 so callback knows there is no * Call callback with resp == NULL and resplen == -1 so callback
* response. * knows there is no response
*/ */
OPENSSL_free(s->tlsext_ocsp_resp);
s->tlsext_ocsp_resp = NULL;
s->tlsext_ocsp_resplen = -1;
r = s->ctx->tlsext_status_cb(s, s->ctx->tlsext_status_arg); r = s->ctx->tlsext_status_cb(s, s->ctx->tlsext_status_arg);
if (r == 0) { if (r == 0) {
al = SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE; al = SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册