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

Remove mbed tls from evsev2g #1008

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MarzellT
Copy link
Member

@MarzellT MarzellT commented Jan 16, 2025

Describe your changes

This Pull Request removes the mbed tls dependency of the EvseV2G module with all its usages. TLS connections will now only be handled by OpenSSL.

Issue ticket number and link

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have made corresponding changes to the documentation
  • I read the contribution documentation and made sure that my changes meet its requirements

@corneliusclaussen
Copy link
Contributor

There are some left overs in:

dependencies.yaml and module-dependencies.cmake

Also please squash commits and provide proper commit description before opening to review

@SebaLukas
Copy link
Contributor

I asked the community about the mbedtls deletion at the Car WG meeting on Wednesday and heard nothing against it. So we can continue here.

@MarzellT MarzellT marked this pull request as draft January 28, 2025 08:44
@SebaLukas SebaLukas self-assigned this Feb 4, 2025
@SebaLukas SebaLukas added the post-release Tag that this PR should not go into the current merge window for the upcoming release label Feb 4, 2025
@MarzellT MarzellT force-pushed the feat/remove-mbed-tls-from-evsev2g branch from 58e2c7a to de3f4b1 Compare February 4, 2025 08:46
Signed-off-by: MarzellT <tobias.marzell@pionix.de>
Copy link
Contributor

@SebaLukas SebaLukas left a comment

Choose a reason for hiding this comment

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

Looking good! Only one question :)

Comment on lines -229 to -237
if (v2g_ctx->tls_security != TLS_SECURITY_PROHIBIT) {
v2g_ctx->local_tls_addr = static_cast<sockaddr_in6*>(calloc(1, sizeof(*v2g_ctx->local_tls_addr)));
connection_ssl_initialize();
if (!v2g_ctx->local_tls_addr) {
dlog(DLOG_LEVEL_ERROR, "Failed to allocate memory for TLS address");
return -1;
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Is the code not needed? Or was v2g_ctx->local_tls_addr only for mbedtls?

Copy link
Contributor

@james-ctc james-ctc Feb 14, 2025

Choose a reason for hiding this comment

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

local_tls_addr is still needed for OpenSSL version.
Background:
connection.cpp does two things:

  1. sets up a TCP connection (for non-TLS connections)
  2. sets up the TLS socket (for both mbedtls and openssl)

the reason was to use the tested socket creation code rather than replace it. The new OpenSSL code can use a specified socket (as done here) or create as socket when needed.
The advantage here is that the SDP needs information on the socket to respond to the UDP request and using the common code means that it didn't need changing.

Copy link
Contributor

Choose a reason for hiding this comment

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

@MarzellT Then please revert removing this code section.

@SebaLukas
Copy link
Contributor

@james-ctc Can you please have a quick look, too? :)

@@ -226,15 +144,6 @@ int connection_init(struct v2g_context* v2g_ctx) {
}
}

if (v2g_ctx->tls_security != TLS_SECURITY_PROHIBIT) {
v2g_ctx->local_tls_addr = static_cast<sockaddr_in6*>(calloc(1, sizeof(*v2g_ctx->local_tls_addr)));
connection_ssl_initialize();
Copy link
Contributor

Choose a reason for hiding this comment

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

the call to connection_ssl_initialize(); can be removed, the rest is still needed

@@ -358,61 +265,37 @@ ssize_t connection_read(struct v2g_connection* conn, unsigned char* buf, size_t

int num_of_bytes;

if (conn->is_tls_connection) {
Copy link
Contributor

Choose a reason for hiding this comment

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

connection_read() should only be used for non-TLS connections.
The removed if statement is a safety check that connection_read() hasn't been accidentally configured for a TLS connection.

@@ -445,28 +328,13 @@ ssize_t connection_write(struct v2g_connection* conn, unsigned char* buf, size_t
while (bytes_written < count) {
int num_of_bytes;

if (conn->is_tls_connection) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The if statement is needed to ensure that connection_write() is not used on a non-TLS connection

Copy link
Contributor

@james-ctc james-ctc left a comment

Choose a reason for hiding this comment

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

Looks good, the main areas of v2g code are removed!
Once tested then the same needs to be applied to the IsoMux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
post-release Tag that this PR should not go into the current merge window for the upcoming release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants