Add detail strings for unexpected_message alerts
@@ -73,7 +73,7 @@ void notifyChangeCipherSpecReceived()
{
if (pendingCipher == null)
{
- throw new TlsFatalAlert(AlertDescription.unexpected_message);
+ throw new TlsFatalAlert(AlertDescription.unexpected_message, "No pending cipher");
}
enablePendingCipherRead(false);
@@ -356,7 +356,8 @@ private void checkChangeCipherSpec(byte[] buf, int off, int len)
{
if (1 != len || (byte)ChangeCipherSpec.change_cipher_spec != buf[off])
{
- throw new TlsFatalAlert(AlertDescription.unexpected_message);
+ throw new TlsFatalAlert(AlertDescription.unexpected_message,
+ "Malformed " + ContentType.getText(ContentType.change_cipher_spec));
}
}
@@ -382,7 +383,8 @@ else if (readCipher.usesOpaqueRecordType())
}
else
{
- throw new TlsFatalAlert(AlertDescription.unexpected_message, ContentType.getText(recordType));
+ throw new TlsFatalAlert(AlertDescription.unexpected_message,
+ "Opaque " + ContentType.getText(recordType));
}
}
}
@@ -394,7 +396,8 @@ else if (readCipher.usesOpaqueRecordType())
{
if (!handler.isApplicationDataReady())
{
- throw new TlsFatalAlert(AlertDescription.unexpected_message);
+ throw new TlsFatalAlert(AlertDescription.unexpected_message,
+ "Not ready for " + ContentType.getText(ContentType.application_data));
}
break;
}
@@ -404,7 +407,8 @@ else if (readCipher.usesOpaqueRecordType())
// case ContentType.heartbeat:
break;
default:
- throw new TlsFatalAlert(AlertDescription.unexpected_message);
+ throw new TlsFatalAlert(AlertDescription.unexpected_message,
+ "Unsupported " + ContentType.getText(recordType));
}
}
@@ -515,7 +519,7 @@ synchronized long nextValue(short alertDescription) throws TlsFatalAlert
{
if (exhausted)
{
- throw new TlsFatalAlert(alertDescription);
+ throw new TlsFatalAlert(alertDescription, "Sequence numbers exhausted");
}
long result = value;
if (++value == 0)
