Skip to content

Commit

Permalink
Pass message/cause parameters to TlsPeer.notifyAlertRaised
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdettman committed Sep 18, 2013
1 parent faee178 commit 1b24265
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions core/src/main/java/org/bouncycastle/crypto/tls/TlsProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -453,23 +453,23 @@ protected void safeReadRecord()
{
if (!this.closed)
{
this.failWithError(AlertLevel.fatal, e.getAlertDescription());
this.failWithError(AlertLevel.fatal, e.getAlertDescription(), "Failed to read record", e);
}
throw e;
}
catch (IOException e)
{
if (!this.closed)
{
this.failWithError(AlertLevel.fatal, AlertDescription.internal_error);
this.failWithError(AlertLevel.fatal, AlertDescription.internal_error, "Failed to read record", e);
}
throw e;
}
catch (RuntimeException e)
{
if (!this.closed)
{
this.failWithError(AlertLevel.fatal, AlertDescription.internal_error);
this.failWithError(AlertLevel.fatal, AlertDescription.internal_error, "Failed to read record", e);
}
throw e;
}
Expand All @@ -486,23 +486,23 @@ protected void safeWriteRecord(short type, byte[] buf, int offset, int len)
{
if (!this.closed)
{
this.failWithError(AlertLevel.fatal, e.getAlertDescription());
this.failWithError(AlertLevel.fatal, e.getAlertDescription(), "Failed to write record", e);
}
throw e;
}
catch (IOException e)
{
if (!closed)
{
this.failWithError(AlertLevel.fatal, AlertDescription.internal_error);
this.failWithError(AlertLevel.fatal, AlertDescription.internal_error, "Failed to write record", e);
}
throw e;
}
catch (RuntimeException e)
{
if (!closed)
{
this.failWithError(AlertLevel.fatal, AlertDescription.internal_error);
this.failWithError(AlertLevel.fatal, AlertDescription.internal_error, "Failed to write record", e);
}
throw e;
}
Expand Down Expand Up @@ -593,7 +593,7 @@ public InputStream getInputStream()
* @throws IOException
* If alert was fatal.
*/
protected void failWithError(short alertLevel, short alertDescription)
protected void failWithError(short alertLevel, short alertDescription, String message, Exception cause)
throws IOException
{
/*
Expand All @@ -617,7 +617,7 @@ protected void failWithError(short alertLevel, short alertDescription)

this.failedWithError = true;
}
raiseAlert(alertLevel, alertDescription, null, null);
raiseAlert(alertLevel, alertDescription, message, cause);
recordStream.safeClose();
if (alertLevel != AlertLevel.fatal)
{
Expand Down Expand Up @@ -774,7 +774,7 @@ protected void handleClose(boolean user_canceled)
{
raiseWarning(AlertDescription.user_canceled, "User canceled handshake");
}
this.failWithError(AlertLevel.warning, AlertDescription.close_notify);
this.failWithError(AlertLevel.warning, AlertDescription.close_notify, "Connection closed", null);
}
}

Expand Down Expand Up @@ -841,7 +841,11 @@ protected static byte[] createRandomBlock(SecureRandom random)
{
byte[] result = new byte[32];
random.nextBytes(result);
TlsUtils.writeGMTUnixTime(result, 0);
/*
* The consensus seems to be that using the time here is neither useful, nor secure. Perhaps
* there could be an option to (re-)enable it.
*/
// TlsUtils.writeGMTUnixTime(result, 0);
return result;
}

Expand Down

0 comments on commit 1b24265

Please sign in to comment.