*/
public void test20MaliciousOcspRequest() throws Exception {
log.trace(">test20MaliciousOcspRequest");
// Start by sending a valid OCSP requests so we know the helpers work
byte validOcspReq[] = getValidOcspRequest();
OCSPResp response = sendRawRequestToOcsp(validOcspReq.length, validOcspReq, false);
assertEquals("Incorrect response status.", OCSPRespGenerator.SUCCESSFUL, response.getStatus());
// Try sending a valid request and then keep sending some more data.
byte[] buf = new byte[LimitLengthASN1Reader.MAX_REQUEST_SIZE * 2];
Arrays.fill(buf, (byte) 123);
buf = concatByteArrays(validOcspReq, buf);
response = sendRawRequestToOcsp(buf.length, buf, false);
assertEquals("Incorrect response status.", OCSPRespGenerator.MALFORMED_REQUEST, response.getStatus());
// Now try with a fake HTTP content-length header
try {
response = sendRawRequestToOcsp(validOcspReq.length, buf, false);
fail("Was able to send a lot of data with a fake HTTP Content-length without any error.");
} catch (IOException e) {
}
// Try sneaking through a payload that is just under the limit. The
// responder will answer politely, but log a warning.
buf = new byte[LimitLengthASN1Reader.MAX_REQUEST_SIZE - validOcspReq.length];
Arrays.fill(buf, (byte) 123);
buf = concatByteArrays(validOcspReq, buf);
response = sendRawRequestToOcsp(buf.length, buf, false);
assertEquals("Server rejected malicious request. (This might be a good thing!)", OCSPRespGenerator.SUCCESSFUL, response.getStatus());
log.trace("<test20MaliciousOcspRequest");
}