-
Notifications
You must be signed in to change notification settings - Fork 642
Download certs into demos/certificates with an option to disable downloading #1126
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
Changes from all commits
3a5d394
f310caa
79c4882
e9d7031
80fd8f0
e72910e
6167e28
46079ac
170cc64
c0ed226
e3fbbe0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,20 +35,21 @@ target_include_directories( | |
| ${LOGGING_INCLUDE_DIRS} | ||
| ) | ||
yourslab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Download the Amazon Root CA certificate. | ||
| message( "Downloading the Amazon Root CA certificate..." ) | ||
| file(MAKE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/certificates) | ||
| execute_process( | ||
| COMMAND curl --url https://www.amazontrust.com/repository/AmazonRootCA1.pem | ||
| -o ${CMAKE_CURRENT_LIST_DIR}/certificates/AmazonRootCA1.crt | ||
| ) | ||
|
|
||
| # Copy the certificates and client key to the binary directory. | ||
| add_custom_command( | ||
| TARGET | ||
| ${DEMO_NAME} | ||
| POST_BUILD | ||
| COMMAND ${CMAKE_COMMAND} -E copy_directory | ||
| "${CMAKE_CURRENT_LIST_DIR}/certificates" | ||
| "$<TARGET_FILE_DIR:${DEMO_NAME}>/certificates" | ||
| ) | ||
| if(ROOT_CA_CERT_PATH) | ||
| target_compile_definitions( | ||
| ${DEMO_NAME} PRIVATE | ||
| ROOT_CA_CERT_PATH="${ROOT_CA_CERT_PATH}" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even if the file path is passed as a cmake flag, will it still work properly from any directory if the given flag is a relative path and not an absolute path? If not, is it possible to parse this flag using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea! |
||
| ) | ||
| endif() | ||
| if(BROKER_ENDPOINT) | ||
| target_compile_definitions( | ||
| ${DEMO_NAME} PRIVATE | ||
| BROKER_ENDPOINT="${BROKER_ENDPOINT}" | ||
| ) | ||
| endif() | ||
| if(CLIENT_IDENTIFIER) | ||
| target_compile_definitions( | ||
| ${DEMO_NAME} PRIVATE | ||
| CLIENT_IDENTIFIER="${CLIENT_IDENTIFIER}" | ||
| ) | ||
| endif() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if these variables are not passed in the CMake command in which case they would (probably) have empty values?
Would these generate invalid variables for the credential variables in that case?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested the
mqtt_demo_basic_tlslocally with not providing theROOT_CA_CERT_PATHwith the following command:cmake .. -DBUILD_TESTS="ON" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS='-Wextra -Wall -O0 -ggdb'The build logs show that the absolute path logic is causing the
ROOT_CA_CERT_PATHCMake variable to be defined even though it wasn't passed by me, and thus, it is building the demo target with an incorrect value (of/home/ubuntu/Repos/aws-iot-device-sdk-embedded-C/build/as can be seen in the logs)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix is simple by just updating each of the nested if conditions to check if their respective CMake variables are defined