Skip to content

Conversation

@JacobBarthelmeh
Copy link
Contributor

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds TLS transport support to wolfHSM for secure client-server communication. The implementation extends the existing TCP transport with TLS encryption using wolfSSL, supporting both certificate-based and PSK (Pre-Shared Key) authentication methods.

Key Changes:

  • New TLS transport layer built on top of TCP transport with wolfSSL integration
  • Support for both mutual TLS authentication and PSK modes
  • Configuration changes to enable TLS/PSK in the build system

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
port/posix/posix_transport_tls.h Header defining TLS transport structures and function declarations
port/posix/posix_transport_tls.c Implementation of TLS transport client/server functions
port/posix/posix_transport_tcp.c Exposed HandleConnect function and fixed null pointer check
examples/posix/wh_posix_server/wh_posix_server_cfg.h Added TLS and PSK configuration function declarations
examples/posix/wh_posix_server/wh_posix_server_cfg.c Implemented TLS and PSK server configuration with certificate loading
examples/posix/wh_posix_server/wh_posix_server.c Added TLS/PSK transport options to CLI
examples/posix/wh_posix_server/user_settings.h Enabled TLS, TLS12, PSK, and debug settings
examples/posix/wh_posix_client/wh_posix_client_cfg.h Added TLS and PSK client configuration declarations
examples/posix/wh_posix_client/wh_posix_client_cfg.c Implemented TLS and PSK client configuration with certificate loading
examples/posix/wh_posix_client/wh_posix_client.c Added TLS/PSK transport options to client CLI

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JacobBarthelmeh JacobBarthelmeh self-assigned this Oct 29, 2025
@JacobBarthelmeh JacobBarthelmeh force-pushed the auth branch 2 times, most recently from e9a4e7e to fcb0a97 Compare October 30, 2025 20:43
@JacobBarthelmeh JacobBarthelmeh marked this pull request as ready for review October 30, 2025 21:10
Copy link
Contributor

@bigbrett bigbrett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick initial skim - I'd like to see test coverage added to this before diving much deeper. Looks very promising though, I'm super excited about this !!!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JacobBarthelmeh
Copy link
Contributor Author

Investigating SHE tests with TLS.

bigbrett
bigbrett previously approved these changes Nov 4, 2025
@bigbrett bigbrett assigned billphipps and unassigned bigbrett Nov 4, 2025
@bigbrett bigbrett requested a review from billphipps November 4, 2025 19:59
@bigbrett
Copy link
Contributor

bigbrett commented Nov 4, 2025

Random thoughts for future work: It would be really cool to have a built-in way to initialize and setup the WOLFSSL_CTX, perhaps even following the config/context paradigm we use elsewhere. Is there any way we can absolve the user from needing to directly manage the context? Or is that a dangerous road to go down? I envision a basic set of wolfSSL configuration options (keys, certs, basic modes) just being supplied in the transport config struct and us taking care of everything else internally.

@JacobBarthelmeh
Copy link
Contributor Author

JacobBarthelmeh commented Nov 24, 2025

Rebased on top of recent examples and yaml changes. Assigning back to me until CI tests are passing

Copy link
Contributor

@billphipps billphipps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just capturing some notes in progress. Good conversation. Let's keep working to figure out the best path forward!

Comment on lines 107 to 114
@scan-build --exclude $(WOLFSSL_DIR)/wolfcrypt \
--exclude $(WOLFSSL_DIR)/src \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were these causing issues before this PR? Recommend to add a comment explaining why it is ok to exclude wolfcrypt here. We should probably consider allowing a system library build of wolfssl for tools rather than building from source

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the --exclude's being in the main wolfHSM branch. Not sure why it would be listed as change in this PR. Maybe from the rebase onto main?

defined(WOLFHSM_CFG_ENABLE_CLIENT) && defined(WOLFHSM_CFG_TEST_POSIX)
/* Test driver should run TCP client tests against the example server */
ret = whTest_ClientTcp();
#elif defined(WOLFHSM_CFG_TEST_CLIENT_ONLY_TLS) && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider combining the xxx_ONLY_TCP and xxx_ONLY_TLS into CLIENT_ONLY and use additional CFG or CFG_TEST to specify the transport. These CFG_TEST macros should be described in wh_test.h with defaults AND the wh_test.h should be included in user_settings.h and wh_config.h to allow those configurations to be overridden.

int whPosixClient_ExampleTlsConfig(void* conf)
{
if (whPosixClient_ExampleTlsCommonConfig(conf) != WH_ERROR_OK) {
return WH_ERROR_ABORTED;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider returning the return value?


#if defined(WOLFHSM_CFG_TEST_POSIX) && defined(WOLFHSM_CFG_ENABLE_CLIENT)
#include "port/posix/posix_transport_tcp.h"
#ifndef WOLFHSM_CFG_NO_CRYPTO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be gated on whether or not TLS is actually needed since the user_settings.h may be different when TLS is needed or not.

Comment on lines -48 to -51
/* For cert manager */
#define NO_TLS
/* Eliminates need for IO layer since we only use CM */
#define WOLFSSL_USER_IO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be gated on whether the TLS transport is necessary in this build. It should be made very clear which wolfCrypt settings are required ONLY for TLS and which are the ones needed for a slim/test version of wolfHSM

Comment on lines +207 to +213
rc = wolfSSL_CTX_load_verify_buffer(ctx->ssl_ctx, ca_cert_der_2048,
sizeof_ca_cert_der_2048,
CTC_FILETYPE_ASN1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend to move CA and device certificates into the TLS transport config structure. These buffers (pointers?) or filenames would get copied into the TLS transport context and then used during the TLS transport Init() callback. This would allow you to instantiate and connect in a single wh_Client_Init() call, rather than build parts of the context out of sequence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants