Skip to content

Commit

Permalink
do not merge
Browse files Browse the repository at this point in the history
  • Loading branch information
kgiusti committed Aug 22, 2024
1 parent a71762d commit 2de85f3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 6 deletions.
46 changes: 40 additions & 6 deletions src/tls/tls_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ int qd_tls_session_do_io(qd_tls_session_t *session,

while (pn_raw_connection_take_written_buffers(raw_conn, &pn_buf_desc, 1) == 1) {
qd_buffer_t *buf = (qd_buffer_t *) pn_buf_desc.context;
///
fprintf(stdout, "E-T2R-F(%"PRIu64"): %u@%p\n", conn_id, pn_buf_desc.size, (void *) (pn_buf_desc.bytes + pn_buf_desc.offset));
assert(qd_buffer_size(buf) == pn_buf_desc.size);
assert(qd_buffer_base(buf) == (unsigned char *) (pn_buf_desc.bytes + pn_buf_desc.offset));
///
qd_buffer_free(buf);
}

Expand All @@ -241,6 +246,11 @@ int qd_tls_session_do_io(qd_tls_session_t *session,
while (abuf) {
DEQ_REMOVE_HEAD(ubufs);
_pn_buf_desc_give_buffer(&pn_buf_desc, abuf);
///
assert(qd_buffer_size(abuf) == pn_buf_desc.size);
assert(qd_buffer_base(abuf) == (unsigned char *) (pn_buf_desc.bytes + pn_buf_desc.offset));
///

given = pn_tls_give_encrypt_input_buffers(session->pn_raw, &pn_buf_desc, 1);
assert(given == 1);
abuf = DEQ_HEAD(ubufs);
Expand Down Expand Up @@ -290,13 +300,20 @@ int qd_tls_session_do_io(qd_tls_session_t *session,
// No more read buffers available. Now it is safe to check if the raw connection has closed
session->raw_read_drained = pn_raw_connection_is_read_closed(raw_conn);
break;
} else if (pn_buf_desc.size) {
total_octets += pn_buf_desc.size;
given = pn_tls_give_decrypt_input_buffers(session->pn_raw, &pn_buf_desc, 1);
assert(given == 1);
++pushed;
} else {
qd_buffer_free((qd_buffer_t *) pn_buf_desc.context);
///
fprintf(stdout, "E-R2T(%"PRIu64"): %u@%p\n", conn_id, pn_buf_desc.size, (void *) (pn_buf_desc.bytes + pn_buf_desc.offset));
qd_buffer_t *abuf = (qd_buffer_t *) pn_buf_desc.context;
abuf->size = pn_buf_desc.size;
///
if (pn_buf_desc.size) {
total_octets += pn_buf_desc.size;
given = pn_tls_give_decrypt_input_buffers(session->pn_raw, &pn_buf_desc, 1);
assert(given == 1);
++pushed;
} else {
qd_buffer_free((qd_buffer_t *) pn_buf_desc.context);
}
}
}
if (pushed > 0) {
Expand Down Expand Up @@ -343,6 +360,11 @@ int qd_tls_session_do_io(qd_tls_session_t *session,
}
while (pushed < capacity && pn_tls_take_encrypt_output_buffers(session->pn_raw, &pn_buf_desc, 1) == 1) {
total_octets += pn_buf_desc.size;
///
fprintf(stdout, "E-T2R(%"PRIu64"): %u@%p\n", conn_id, pn_buf_desc.size, (void *) (pn_buf_desc.bytes + pn_buf_desc.offset));
qd_buffer_t *abuf = (qd_buffer_t *) pn_buf_desc.context;
abuf->size = pn_buf_desc.size;
///
given = pn_raw_connection_write_buffers(raw_conn, &pn_buf_desc, 1);
assert(given == 1);
++pushed;
Expand Down Expand Up @@ -379,6 +401,8 @@ int qd_tls_session_do_io(qd_tls_session_t *session,
taken = 0;
while (pn_tls_take_decrypt_output_buffers(session->pn_raw, &pn_buf_desc, 1) == 1) {
qd_buffer_t *abuf = _pn_buf_desc_take_buffer(&pn_buf_desc);
assert(qd_buffer_size(abuf) == pn_buf_desc.size);
assert(qd_buffer_base(abuf) == (unsigned char *) (pn_buf_desc.bytes + pn_buf_desc.offset));
if (qd_buffer_size(abuf)) {
total_octets += qd_buffer_size(abuf);
DEQ_INSERT_TAIL(*input_data, abuf);
Expand Down Expand Up @@ -406,12 +430,22 @@ int qd_tls_session_do_io(qd_tls_session_t *session,
while (pn_tls_take_encrypt_input_buffers(session->pn_raw, &pn_buf_desc, 1) == 1) {
qd_buffer_t *abuf = (qd_buffer_t *) pn_buf_desc.context;
assert(abuf);
///
assert(qd_buffer_size(abuf) == pn_buf_desc.size);
assert(qd_buffer_base(abuf) == (unsigned char *) (pn_buf_desc.bytes + pn_buf_desc.offset));
///
qd_buffer_free(abuf);
++taken;
}
while (pn_tls_take_decrypt_input_buffers(session->pn_raw, &pn_buf_desc, 1) == 1) {
qd_buffer_t *abuf = (qd_buffer_t *) pn_buf_desc.context;
assert(abuf);
///
fprintf(stdout, "E-R2T-F(%"PRIu64"): %u@%p\n", conn_id, pn_buf_desc.size, (void *) (pn_buf_desc.bytes + pn_buf_desc.offset));
assert(qd_buffer_size(abuf) == pn_buf_desc.size);
assert(qd_buffer_base(abuf) == (unsigned char *) (pn_buf_desc.bytes + pn_buf_desc.offset));
///

qd_buffer_free(abuf);
++taken;
}
Expand Down
7 changes: 7 additions & 0 deletions tests/system_tests_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,7 @@ def test_ssl_client_profile_update(self):
"""
Verify updates to the sslProfiles for client connections
"""
debug = True

payload = "?" * 1024 * 65
payload += "TLS Message!"
Expand All @@ -1090,6 +1091,7 @@ def test_ssl_client_profile_update(self):
test_rx = AsyncTestReceiver(f"amqps://localhost:{self.listener1_port}",
source="test/addr",
container_id="FooRx",
print_to_console=debug,
conn_args=conn_args)

ssl_domain = SSLDomain(SSLDomain.MODE_CLIENT)
Expand All @@ -1104,6 +1106,7 @@ def test_ssl_client_profile_update(self):
message=message,
container_id="FooTx",
conn_args=conn_args,
print_to_console=debug,
get_link_info=False)
test_tx.wait()
test_rx.stop()
Expand Down Expand Up @@ -1143,6 +1146,7 @@ def test_ssl_client_profile_update(self):
AsyncTestReceiver(f"amqps://localhost:{self.listener1_port}",
source="test/addr",
container_id="FooRx2",
print_to_console=debug,
conn_args=conn_args)
self.assertIn("certificate verify failed", str(exc.exception), f"{exc.exception}")

Expand All @@ -1157,6 +1161,7 @@ def test_ssl_client_profile_update(self):
AsyncTestReceiver(f"amqps://localhost:{self.listener2_port}",
source="test/addr",
container_id="FooRx3",
print_to_console=debug,
conn_args=conn_args)
self.assertIn("certificate verify failed", str(exc.exception), f"{exc.exception}")

Expand All @@ -1174,6 +1179,7 @@ def test_ssl_client_profile_update(self):
test_rx = AsyncTestReceiver(f"amqps://localhost:{self.listener1_port}",
source="test/addr",
container_id="FooRxOk",
print_to_console=debug,
conn_args=conn_args)

ssl_domain = SSLDomain(SSLDomain.MODE_CLIENT)
Expand All @@ -1188,6 +1194,7 @@ def test_ssl_client_profile_update(self):
message=message,
container_id="FooTxOk",
conn_args=conn_args,
print_to_console=debug,
get_link_info=False)
test_tx.wait()
test_rx.stop()
Expand Down

0 comments on commit 2de85f3

Please sign in to comment.