TSG-16294: client hello分数据包传输时,支持识别SSL协议

This commit is contained in:
liuxueli
2023-09-06 18:42:57 +08:00
parent 12a97dede4
commit 8934001da6
3 changed files with 26 additions and 12 deletions

View File

@@ -1487,6 +1487,16 @@ int session_l7_protocol_identify(const struct streaminfo *a_stream, struct sessi
return 1;
}
if(chello!=NULL)
{
if(chello->is_ssl==1)
{
srt_process_context->proto=PROTO_SSL;
ssl_chello_free(chello);
return 1;
}
}
ssl_chello_free(chello);
}

View File

@@ -299,6 +299,7 @@ struct ssl_chello* ssl_chello_parse(const unsigned char* buff, size_t buff_len,
*result = CHELLO_PARSE_INVALID_FORMAT;
return _chello;
}
_chello->max_version.major = buff[pos];
_chello->max_version.minor = buff[pos + 1];
_chello->max_version.ossl_format=(uint16_t)_chello->max_version.major<<8|_chello->max_version.minor;
@@ -307,7 +308,7 @@ struct ssl_chello* ssl_chello_parse(const unsigned char* buff, size_t buff_len,
}
else
{
if (buff_len < 5)
if (buff_len < 6)
{
*result = CHELLO_PARSE_NOT_ENOUGH_BUFF;
return NULL;
@@ -317,6 +318,12 @@ struct ssl_chello* ssl_chello_parse(const unsigned char* buff, size_t buff_len,
*result = CHELLO_PARSE_INVALID_FORMAT;
return NULL;
}
if (buff[5] != 0x01)
{
*result = CHELLO_PARSE_INVALID_FORMAT;
return NULL;
}
struct ssl_chello* _chello = (struct ssl_chello*)ALLOC(struct ssl_chello, 1);
_chello->min_version.major = buff[1];
_chello->min_version.minor = buff[2];
@@ -325,6 +332,11 @@ struct ssl_chello* ssl_chello_parse(const unsigned char* buff, size_t buff_len,
_chello->max_version.minor = (uint8_t)(-1);
_chello->sni = NULL;
if(buff[0] == 0x16)
{
_chello->is_ssl=1;
}
/* TLS record length */
size_t len = ((size_t)buff[3] << 8) + (size_t)buff[4] + 5;
if (buff_len < len)
@@ -333,17 +345,8 @@ struct ssl_chello* ssl_chello_parse(const unsigned char* buff, size_t buff_len,
return _chello;
}
buff_len = len;
size_t pos = 5;
if (pos + 1 > buff_len)
{
*result = CHELLO_PARSE_INVALID_FORMAT;
return _chello;
}
if (buff[pos] != 0x01)
{
*result = CHELLO_PARSE_INVALID_FORMAT;
return _chello;
}
size_t pos = 6;
pos += 4;
if(pos + 2 > buff_len)
{

View File

@@ -26,6 +26,7 @@ struct ssl_chello
struct ssl_version max_version;
char* sni;
int is_ssl;
int is_encrypt_sni;
int is_encrypt_chello;
};