Update pre9
This commit is contained in:
@@ -3472,6 +3472,15 @@ long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
|
||||
break;
|
||||
#endif /* !OPENSSL_NO_EC */
|
||||
case SSL_CTRL_SET_TLSEXT_HOSTNAME:
|
||||
/*
|
||||
* TODO(OpenSSL1.2)
|
||||
* This API is only used for a client to set what SNI it will request
|
||||
* from the server, but we currently allow it to be used on servers
|
||||
* as well, which is a programming error. Currently we just clear
|
||||
* the field in SSL_do_handshake() for server SSLs, but when we can
|
||||
* make ABI-breaking changes, we may want to make use of this API
|
||||
* an error on server SSLs.
|
||||
*/
|
||||
if (larg == TLSEXT_NAMETYPE_host_name) {
|
||||
size_t len;
|
||||
|
||||
|
||||
@@ -757,6 +757,7 @@ static const ERR_STRING_DATA SSL_str_reasons[] = {
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_HRR_VERSION), "bad hrr version"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_KEY_SHARE), "bad key share"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_KEY_UPDATE), "bad key update"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_LEGACY_VERSION), "bad legacy version"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_LENGTH), "bad length"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_PACKET), "bad packet"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_BAD_PACKET_LENGTH), "bad packet length"},
|
||||
@@ -1139,6 +1140,10 @@ static const ERR_STRING_DATA SSL_str_reasons[] = {
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_SSL_SESSION_VERSION_MISMATCH),
|
||||
"ssl session version mismatch"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_STILL_IN_INIT), "still in init"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_TLSV13_ALERT_CERTIFICATE_REQUIRED),
|
||||
"tlsv13 alert certificate required"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_TLSV13_ALERT_MISSING_EXTENSION),
|
||||
"tlsv13 alert missing extension"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_TLSV1_ALERT_ACCESS_DENIED),
|
||||
"tlsv1 alert access denied"},
|
||||
{ERR_PACK(ERR_LIB_SSL, 0, SSL_R_TLSV1_ALERT_DECODE_ERROR),
|
||||
|
||||
+12
-1
@@ -2678,7 +2678,18 @@ const char *SSL_get_servername(const SSL *s, const int type)
|
||||
if (type != TLSEXT_NAMETYPE_host_name)
|
||||
return NULL;
|
||||
|
||||
return s->session && !s->ext.hostname ?
|
||||
/*
|
||||
* TODO(OpenSSL1.2) clean up this compat mess. This API is
|
||||
* currently a mix of "what did I configure" and "what did the
|
||||
* peer send" and "what was actually negotiated"; we should have
|
||||
* a clear distinction amongst those three.
|
||||
*/
|
||||
if (SSL_in_init(s)) {
|
||||
if (s->hit)
|
||||
return s->session->ext.hostname;
|
||||
return s->ext.hostname;
|
||||
}
|
||||
return (s->session != NULL && s->ext.hostname == NULL) ?
|
||||
s->session->ext.hostname : s->ext.hostname;
|
||||
}
|
||||
|
||||
|
||||
@@ -421,15 +421,6 @@ int ssl_get_new_session(SSL *s, int session)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (s->ext.hostname) {
|
||||
ss->ext.hostname = OPENSSL_strdup(s->ext.hostname);
|
||||
if (ss->ext.hostname == NULL) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GET_NEW_SESSION,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
SSL_SESSION_free(ss);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ss->session_id_length = 0;
|
||||
}
|
||||
|
||||
+22
-3
@@ -929,9 +929,28 @@ static int final_server_name(SSL *s, unsigned int context, int sent)
|
||||
ret = s->session_ctx->ext.servername_cb(s, &altmp,
|
||||
s->session_ctx->ext.servername_arg);
|
||||
|
||||
if (!sent) {
|
||||
OPENSSL_free(s->session->ext.hostname);
|
||||
s->session->ext.hostname = NULL;
|
||||
/*
|
||||
* For servers, propagate the SNI hostname from the temporary
|
||||
* storage in the SSL to the persistent SSL_SESSION, now that we
|
||||
* know we accepted it.
|
||||
* Clients make this copy when parsing the server's response to
|
||||
* the extension, which is when they find out that the negotiation
|
||||
* was successful.
|
||||
*/
|
||||
if (s->server) {
|
||||
if (!sent) {
|
||||
/* Nothing from the client this handshake; cleanup stale value */
|
||||
OPENSSL_free(s->ext.hostname);
|
||||
s->ext.hostname = NULL;
|
||||
} else if (ret == SSL_TLSEXT_ERR_OK && (!s->hit || SSL_IS_TLS13(s))) {
|
||||
/* Only store the hostname in the session if we accepted it. */
|
||||
OPENSSL_free(s->session->ext.hostname);
|
||||
s->session->ext.hostname = OPENSSL_strdup(s->ext.hostname);
|
||||
if (s->session->ext.hostname == NULL && s->ext.hostname != NULL) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_FINAL_SERVER_NAME,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -127,7 +127,7 @@ int tls_parse_ctos_server_name(SSL *s, PACKET *pkt, unsigned int context,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!s->hit) {
|
||||
if (!s->hit || SSL_IS_TLS13(s)) {
|
||||
if (PACKET_remaining(&hostname) > TLSEXT_MAXLEN_host_name) {
|
||||
SSLfatal(s, SSL_AD_UNRECOGNIZED_NAME,
|
||||
SSL_F_TLS_PARSE_CTOS_SERVER_NAME,
|
||||
@@ -142,21 +142,26 @@ int tls_parse_ctos_server_name(SSL *s, PACKET *pkt, unsigned int context,
|
||||
return 0;
|
||||
}
|
||||
|
||||
OPENSSL_free(s->session->ext.hostname);
|
||||
s->session->ext.hostname = NULL;
|
||||
if (!PACKET_strndup(&hostname, &s->session->ext.hostname)) {
|
||||
/*
|
||||
* Store the requested SNI in the SSL as temporary storage.
|
||||
* If we accept it, it will get stored in the SSL_SESSION as well.
|
||||
*/
|
||||
OPENSSL_free(s->ext.hostname);
|
||||
s->ext.hostname = NULL;
|
||||
if (!PACKET_strndup(&hostname, &s->ext.hostname)) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PARSE_CTOS_SERVER_NAME,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
s->servername_done = 1;
|
||||
} else {
|
||||
}
|
||||
if (s->hit) {
|
||||
/*
|
||||
* TODO(openssl-team): if the SNI doesn't match, we MUST
|
||||
* fall back to a full handshake.
|
||||
*/
|
||||
s->servername_done = s->session->ext.hostname
|
||||
s->servername_done = (s->session->ext.hostname != NULL)
|
||||
&& PACKET_equal(&hostname, s->session->ext.hostname,
|
||||
strlen(s->session->ext.hostname));
|
||||
|
||||
@@ -1325,7 +1330,7 @@ EXT_RETURN tls_construct_stoc_server_name(SSL *s, WPACKET *pkt,
|
||||
size_t chainidx)
|
||||
{
|
||||
if (s->hit || s->servername_done != 1
|
||||
|| s->session->ext.hostname == NULL)
|
||||
|| s->ext.hostname == NULL)
|
||||
return EXT_RETURN_NOT_SENT;
|
||||
|
||||
if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_server_name)
|
||||
|
||||
+3
-3
@@ -68,17 +68,17 @@ OSSL_HANDSHAKE_STATE SSL_get_state(const SSL *ssl)
|
||||
return ssl->statem.hand_state;
|
||||
}
|
||||
|
||||
int SSL_in_init(SSL *s)
|
||||
int SSL_in_init(const SSL *s)
|
||||
{
|
||||
return s->statem.in_init;
|
||||
}
|
||||
|
||||
int SSL_is_init_finished(SSL *s)
|
||||
int SSL_is_init_finished(const SSL *s)
|
||||
{
|
||||
return !(s->statem.in_init) && (s->statem.hand_state == TLS_ST_OK);
|
||||
}
|
||||
|
||||
int SSL_in_before(SSL *s)
|
||||
int SSL_in_before(const SSL *s)
|
||||
{
|
||||
/*
|
||||
* Historically being "in before" meant before anything had happened. In the
|
||||
|
||||
@@ -1753,6 +1753,18 @@ int ssl_choose_server_version(SSL *s, CLIENTHELLO_MSG *hello, DOWNGRADE *dgrd)
|
||||
return SSL_R_LENGTH_MISMATCH;
|
||||
}
|
||||
|
||||
/*
|
||||
* The TLSv1.3 spec says the client MUST set this to TLS1_2_VERSION.
|
||||
* The spec only requires servers to check that it isn't SSLv3:
|
||||
* "Any endpoint receiving a Hello message with
|
||||
* ClientHello.legacy_version or ServerHello.legacy_version set to
|
||||
* 0x0300 MUST abort the handshake with a "protocol_version" alert."
|
||||
* We are slightly stricter and require that it isn't SSLv3 or lower.
|
||||
* We tolerate TLSv1 and TLSv1.1.
|
||||
*/
|
||||
if (client_version <= SSL3_VERSION)
|
||||
return SSL_R_BAD_LEGACY_VERSION;
|
||||
|
||||
while (PACKET_get_net_2(&versionslist, &candidate_vers)) {
|
||||
/* TODO(TLS1.3): Remove this before release */
|
||||
if (candidate_vers == TLS1_3_VERSION_DRAFT
|
||||
|
||||
+2
-1
@@ -701,7 +701,8 @@ int tls13_update_key(SSL *s, int sending)
|
||||
|
||||
int tls13_alert_code(int code)
|
||||
{
|
||||
if (code == SSL_AD_MISSING_EXTENSION)
|
||||
/* There are 2 additional alerts in TLSv1.3 compared to TLSv1.2 */
|
||||
if (code == SSL_AD_MISSING_EXTENSION || code == SSL_AD_CERTIFICATE_REQUIRED)
|
||||
return code;
|
||||
|
||||
return tls1_alert_code(code);
|
||||
|
||||
Reference in New Issue
Block a user