CertificateRequestSerializer extends HandshakeMessageSerializer<CertificateRequestMessage> { @Override public byte[] serializeHandshakeMessageContent() { LOGGER.debug("Serializing CertificateRequestMessage"); if (version.isTLS13()) { writeCertificateRquestContextLength(msg); writeCertificateRquestContext(msg); writeExtensionLength(); writeExtensionBytes(); } else { writeClientCertificateTypesCount(msg); writeClientCertificateTypes(msg); if (version == ProtocolVersion.TLS12 || version == ProtocolVersion.DTLS12) { writeSignatureHandshakeAlgorithmsLength(msg); writeSignatureHandshakeAlgorithms(msg); } writeDistinguishedNamesLength(msg); if (hasDistinguishedNames(msg)) { writeDistinguishedNames(msg); } } return getAlreadySerialized(); } CertificateRequestSerializer(CertificateRequestMessage message, ProtocolVersion version); @Override byte[] serializeHandshakeMessageContent();  }
@Test public void testSerializeHandshakeMessageContent() { CertificateRequestMessage message = new CertificateRequestMessage(); message.setLength(length); message.setType(type.getValue()); message.setClientCertificateTypesCount(certTypesCount); message.setClientCertificateTypes(certTypes); message.setSignatureHashAlgorithmsLength(sigHashAlgsLength); message.setSignatureHashAlgorithms(sigHashAlgs); message.setDistinguishedNamesLength(distinguishedNamesLength); message.setDistinguishedNames(disitinguishedNames); CertificateRequestSerializer serializer = new CertificateRequestSerializer(message, version); assertArrayEquals(expectedPart, serializer.serialize()); }