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

Initial draft for certificate generation #399

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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: 0 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
option(CREATE_SYMLINKS "Create symlinks to javascript modules and auxillary files - for development purposes" OFF)
option(CMAKE_RUN_CLANG_TIDY "Run clang-tidy" OFF)
option(BUILD_TESTING "Run unit tests" OFF)
option(ISO15118_2_GENERATE_AND_INSTALL_CERTIFICATES "Automatically generate and install certificates for development purposes" ON)
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like there is no way to turn off certificate generation, but I think one should still be able to provide their own certificates if they so choose

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, this needs to be discussed - therefor I didn't at it yet

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree certificate generation should be an option


# This is a flag for building development tests, but not necessarily to run them, for expample in case
# tests requires hardware.
Expand Down Expand Up @@ -76,11 +75,6 @@ include(ev-project-bootstrap)

ev_add_project()

# create MF_ROOT_CA if not available
if (ISO15118_2_GENERATE_AND_INSTALL_CERTIFICATES)
file(TOUCH config/certs/ca/mf/MF_ROOT_CA.pem)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this file is not generated in the generate_certificates.py but its absence breaks OCPP

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, thanks! I need to check this, haven't tested yet, if the generated files are sufficient for running sil stuff. But here I would rather at the generation of these necessary files into the generator script

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 be mitigated with https://github.com/EVerest/libevse-security/tree/workaround/missing_certificates , which attempts to create the files that are configured but do not yet exist within the libevse-security. @AssemblyJohn

endif()

# config
# FIXME (aw): this should be optional
add_subdirectory(config)
Expand Down
30 changes: 24 additions & 6 deletions config/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
add_subdirectory(nodered)

generate_config_run_script(CONFIG sil)
generate_config_run_script(CONFIG sil-two-evse)
generate_config_run_script(CONFIG sil-ocpp)
Expand All @@ -18,17 +20,33 @@ install(
FILES_MATCHING PATTERN "*.yaml"
)

# install certificates

install(
DIRECTORY "certs"
FILES "${EVEREST_CONFIG_ASSET_DIR}/logging.ini"
DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/everest"
FILES_MATCHING PATTERN "*.pem" PATTERN "*.key" PATTERN "*.der" PATTERN "*.txt" PATTERN "*.jks" PATTERN "*.p12"
RENAME "default_logging.cfg"
)

# generate and install certificates
set(PKI_GENERATOR_SCRIPT ${PROJECT_SOURCE_DIR}/script/simple/generate_certificates.py)
set(PKI_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/certs)
set(PKI_GENERATION_STAMP_FILE ${PKI_OUTPUT_DIR}/.stamp)

add_custom_command(OUTPUT ${PKI_GENERATION_STAMP_FILE}
COMMAND ${CMAKE_COMMAND} -E remove_directory ${PKI_OUTPUT_DIR}
COMMAND ${PKI_GENERATOR_SCRIPT} --output-dir ${PKI_OUTPUT_DIR}
COMMAND ${CMAKE_COMMAND} -E touch ${PKI_GENERATION_STAMP_FILE}
COMMENT "Generating V2G PKI"
DEPENDS ${PKI_GENERATOR_SCRIPT}
)

add_custom_target(everest_core_generate_v2g_pki ALL
DEPENDS ${PKI_GENERATION_STAMP_FILE}
)

install(
FILES "${EVEREST_CONFIG_ASSET_DIR}/logging.ini"
DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/certs"
DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/everest"
RENAME "default_logging.cfg"
FILES_MATCHING PATTERN "*.pem" PATTERN "*.key" PATTERN "*.der" PATTERN "*.txt" PATTERN "*.jks" PATTERN "*.p12"
)

add_subdirectory(nodered)
13 changes: 0 additions & 13 deletions config/certs/.gitignore
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing this directory structure does make it a bit harder to provide your own certificates in the required structure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, but I think it would be a bad idea to put your certificates as an external user into the source tree of everest-core. This should be done differently and will be the responsibility of the external user

Copy link
Contributor

Choose a reason for hiding this comment

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

With the libevse-security and the EvseSecurity module we now have more flexibility configuring certificate paths and directories and we dont rely on a fixed structure like we did before. We need to have some documentation in everest-core / EvseSecurity module that explains how custom certificates can be configured

This file was deleted.

2 changes: 0 additions & 2 deletions config/certs/ca/csms/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions config/certs/ca/cso/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions config/certs/ca/mf/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions config/certs/ca/mo/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions config/certs/ca/oem/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions config/certs/ca/v2g/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions config/certs/client/cps/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions config/certs/client/csms/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions config/certs/client/cso/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions config/certs/client/mf/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions config/certs/client/mo/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions config/certs/client/oem/.gitignore

This file was deleted.

Loading