Skip to content

Commit b22242d

Browse files
authored
Refactoring TLS 1.3 support (#86)
Refactoring connection_ssl: Updating TLS1.3 support, setting verify mode based on tls version, generate the vehicle cert leaf hash for pause/resume, added a standalone connection_openssl test / standalone tls server to test the server, generate own certs for this tls server and openssl client Signed-off-by: Sebastian Lukas <sebastian.lukas@pionix.de>
1 parent dccbf01 commit b22242d

33 files changed

+854
-36
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
*build
22
.vscode
3-
pki
3+
/pki
44
test/sample_data

include/iso15118/config.hpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Copyright 2023 Pionix GmbH and Contributors to EVerest
33
#pragma once
44

5+
#include <filesystem>
56
#include <optional>
67
#include <string>
78

@@ -17,16 +18,21 @@ enum class CertificateBackend {
1718
EVEREST_LAYOUT,
1819
JOSEPPA_LAYOUT,
1920
};
21+
2022
struct SSLConfig {
21-
CertificateBackend backend;
23+
CertificateBackend backend{CertificateBackend::EVEREST_LAYOUT};
2224
// Used by the JOSEPPA_LAYOUT
2325
std::string config_string;
2426
// Used by the EVEREST_LAYOUT
2527
std::string path_certificate_chain;
2628
std::string path_certificate_key;
27-
std::optional<std::string> private_key_password;
29+
std::optional<std::string> private_key_password{};
30+
std::string path_certificate_v2g_root;
31+
std::string path_certificate_mo_root;
2832
bool enable_ssl_logging{false};
2933
bool enable_tls_key_logging{false};
34+
bool enforce_tls_1_3{false};
35+
std::filesystem::path tls_key_logging_path{};
3036
};
3137

3238
} // namespace iso15118::config
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// Copyright 2024 Pionix GmbH and Contributors to EVerest
3+
#pragma once
4+
5+
#include <array>
6+
#include <cstdint>
7+
8+
namespace iso15118::io {
9+
10+
constexpr std::size_t sha_512_hash_size = 64;
11+
using sha512_hash_t = std::array<uint8_t, sha_512_hash_size>;
12+
13+
} // namespace iso15118::io

include/iso15118/io/connection_abstract.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44

55
#include <cstddef>
66
#include <functional>
7+
#include <optional>
78

89
#include "ipv6_endpoint.hpp"
910

11+
#include <iso15118/detail/io/sha_hash.hpp>
12+
1013
namespace iso15118::io {
1114

1215
enum class ConnectionEvent {
@@ -33,6 +36,8 @@ struct IConnection {
3336

3437
virtual void close() = 0;
3538

39+
virtual std::optional<sha512_hash_t> get_vehicle_cert_hash() const = 0;
40+
3641
virtual ~IConnection() = default;
3742
};
3843
} // namespace iso15118::io

include/iso15118/io/connection_plain.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class ConnectionPlain : public IConnection {
2121

2222
void close() final;
2323

24+
std::optional<sha512_hash_t> get_vehicle_cert_hash() const final {
25+
return std::nullopt;
26+
}
27+
2428
~ConnectionPlain();
2529

2630
private:

include/iso15118/io/connection_ssl.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
#include "connection_abstract.hpp"
55

66
#include <memory>
7+
#include <optional>
78

89
#include <iso15118/config.hpp>
10+
#include <iso15118/detail/io/sha_hash.hpp>
911
#include <iso15118/io/poll_manager.hpp>
1012

1113
namespace iso15118::io {
@@ -24,6 +26,8 @@ class ConnectionSSL : public IConnection {
2426

2527
void close() final;
2628

29+
std::optional<sha512_hash_t> get_vehicle_cert_hash() const final;
30+
2731
~ConnectionSSL();
2832

2933
private:

include/iso15118/io/sdp_server.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,13 @@ class TlsKeyLoggingServer {
5353
return fd;
5454
}
5555

56+
auto get_port() const {
57+
return port;
58+
}
59+
5660
private:
5761
int fd{-1};
62+
uint16_t port{0};
5863
sockaddr_in6 destination_address{};
5964
};
6065

include/iso15118/tbd_controller.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
namespace iso15118 {
2121

2222
struct TbdConfig {
23-
config::SSLConfig ssl{config::CertificateBackend::EVEREST_LAYOUT, {}, {}, {}, {}};
23+
config::SSLConfig ssl{config::CertificateBackend::EVEREST_LAYOUT, {}, {}, {}, {}, {}, {}};
2424
std::string interface_name;
2525
config::TlsNegotiationStrategy tls_negotiation_strategy{config::TlsNegotiationStrategy::ACCEPT_CLIENT_OFFER};
2626
bool enable_sdp_server{true};

0 commit comments

Comments
 (0)