make sure handshake complete before sending encrypted alert

This commit is contained in:
toddouska 2012-12-28 14:29:15 -08:00
parent 6d3728fe61
commit f073f49ead

View File

@ -4548,7 +4548,9 @@ int SendAlert(CYASSL* ssl, int severity, int type)
input[0] = (byte)severity; input[0] = (byte)severity;
input[1] = (byte)type; input[1] = (byte)type;
if (ssl->keys.encryptionOn) /* only send encrypted alert if handshake actually complete, otherwise
other side may not be able to handle it */
if (ssl->keys.encryptionOn && ssl->options.handShakeState == HANDSHAKE_DONE)
sendSz = BuildMessage(ssl, output, input, ALERT_SIZE, alert); sendSz = BuildMessage(ssl, output, input, ALERT_SIZE, alert);
else { else {
RecordLayerHeader *const rl = (RecordLayerHeader*)output; RecordLayerHeader *const rl = (RecordLayerHeader*)output;