Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small test and documentation fixes #347

Merged
merged 4 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ where
}

// An implementation of BoxCastPtr means that when we give C code a pointer to the relevant type,
// it is actually a Box.
// it is actually a Box. At most one of BoxCastPtr or ArcCastPtr should be implemented for a given
// type.
pub(crate) trait BoxCastPtr: CastPtr + Sized {
fn to_box(ptr: *mut Self) -> Option<Box<Self::RustType>> {
if ptr.is_null() {
Expand All @@ -351,7 +352,8 @@ pub(crate) trait BoxCastPtr: CastPtr + Sized {
}

// An implementation of ArcCastPtr means that when we give C code a pointer to the relevant type,
// it is actually a Arc.
// it is actually a Arc. At most one of BoxCastPtr or ArcCastPtr should be implemented for a given
// // type.
pub(crate) trait ArcCastPtr: CastConstPtr + Sized {
/// Sometimes we create an Arc, then call `into_raw` and return the resulting raw pointer
/// to C. C can then call rustls_server_session_new multiple times using that
Expand Down
6 changes: 5 additions & 1 deletion tests/client-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def wait_tcp_port(host, port):
break
else:
if i > 0:
print("client-server.py: still trying to connect to host{}:{port}")
print(f"client-server.py: still trying to connect to {host}:{port}")
time.sleep(0.1)
else:
print("client-server.py: unable to connect")
Expand Down Expand Up @@ -200,13 +200,15 @@ def main():
sys.exit(1)

# Standard client/server tests.
print("\n### Standard client/server tests\n")
server_popen = run_server(server, valgrind, {})
wait_tcp_port(HOST, PORT)
run_client_tests(client, valgrind)
server_popen.kill()
server_popen.wait()

# Client/server tests w/ vectored I/O.
print("\n### Vectored I/O client/server tests\n")
server_popen = run_server(server, valgrind, {
"VECTORED_IO": ""
})
Expand All @@ -216,6 +218,7 @@ def main():
server_popen.wait()

# Client/server tests w/ mandatory client authentication.
print("\n### Mandatory mTLS client/server tests\n")
server_popen = run_server(server, valgrind, {
"AUTH_CERT": "testdata/minica.pem",
})
Expand All @@ -225,6 +228,7 @@ def main():
server_popen.wait()

# Client/server tests w/ mandatory client authentication & CRL.
print("\n### Mandatory mTLS w/ CRLs client/server tests\n")
run_server(server, valgrind, {
"AUTH_CERT": "testdata/minica.pem",
"AUTH_CRL": "testdata/test.crl.pem",
Expand Down
5 changes: 4 additions & 1 deletion tests/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,11 @@ main(int argc, const char **argv)
}

client_cert_root_store = rustls_root_cert_store_new();
rustls_root_cert_store_add_pem(
result = rustls_root_cert_store_add_pem(
client_cert_root_store, (uint8_t *)certbuf, certbuf_len, true);
if(result != RUSTLS_RESULT_OK) {
goto cleanup;
}
client_cert_verifier_builder =
rustls_allow_any_authenticated_client_builder_new(
client_cert_root_store);
Expand Down