private void sendClientCertificate(Certificate clientCert) throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    TlsUtils.writeUint8(HandshakeType.certificate, bos);

    // Reserve space for length
    TlsUtils.writeUint24(0, bos);

    clientCert.encode(bos);
    byte[] message = bos.toByteArray();

    // Patch actual length back in
    TlsUtils.writeUint24(message.length - 4, message, 1);

    rs.writeMessage(ContentType.handshake, message, 0, message.length);
  }