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

Move credentials check to be part of run-time application checks #16

Merged
Merged
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
1 change: 1 addition & 0 deletions .github/.cSpellWords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ ECJPAKE
ecdh
ECDH
ECKEY
endpointid
fsanitize
FVPs
havege
Expand Down
19 changes: 6 additions & 13 deletions Config/aws_configs/aws_clientcredential.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,24 @@
*
* For AWS IoT MQTT broker, this is the Thing's REST API Endpoint.
*
* @note Your AWS IoT Core endpoint can be found in the AWS IoT console under
* @note Replace the used dummy value "dummy.endpointid.amazonaws.com" by your
* AWS IoT Core endpoint which can be found in the AWS IoT console under
* Settings/Custom Endpoint, or using the describe-endpoint REST API (with
* AWS CLI command line tool).
*
*/

/* #define clientcredentialMQTT_BROKER_ENDPOINT "" */

#ifndef clientcredentialMQTT_BROKER_ENDPOINT
#error "Uncomment the clientcredentialMQTT_BROKER_ENDPOINT macro above and insert AWS IoT Core endpoint"
#endif /* clientcredentialMQTT_BROKER_ENDPOINT */
#define clientcredentialMQTT_BROKER_ENDPOINT "dummy.endpointid.amazonaws.com"

/**
* @brief The MQTT client identifier used in this example. Each client identifier
* must be unique; so edit as required to ensure that no two clients connecting to
* the same broker use the same client identifier.
* must be unique; so replace the used dummy value "dummy_thingname" as required to
* ensure that no two clients connecting to the same broker use the same client identifier.
*
* Value is defined in "aws_clientcredential.h".
*/

/* #define clientcredentialIOT_THING_NAME "" */

#ifndef clientcredentialIOT_THING_NAME
#error "Uncomment the clientcredentialIOT_THING_NAME macro above and insert MQTT client identifier"
#endif /* clientcredentialIOT_THING_NAME */
#define clientcredentialIOT_THING_NAME "dummy_thingname"

/**
* @brief The port to use for the demo.
Expand Down
19 changes: 19 additions & 0 deletions Projects/aws-iot-example/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <stdlib.h>

#include "app_config.h"
#include "aws_clientcredential.h"
#include "dev_mode_key_provisioning.h"

#include "mqtt_agent_task.h"
Expand Down Expand Up @@ -61,6 +62,19 @@ extern BaseType_t xStartPubSubTasks( uint32_t ulNumPubsubTasks,

extern uint32_t tfm_ns_interface_init( void );

static bool xAreAwsCredentialsValid( void )
{
if( ( strcmp( clientcredentialMQTT_BROKER_ENDPOINT, "dummy.endpointid.amazonaws.com" ) == 0 ) ||
( strcmp( clientcredentialIOT_THING_NAME, "dummy_thingname" ) == 0 ) )
{
printf( "[ERR] INVALID BROKER ENDPOINT AND/OR THING NAME.\r\n" );
printf( "[ERR] Set the right credentials in aws_clientcredential.h\r\n" );
return false;
}

return true;
}

void vAssertCalled( const char * pcFile,
unsigned long ulLine )
{
Expand Down Expand Up @@ -151,6 +165,11 @@ int main()

bsp_serial_init();

if( xAreAwsCredentialsValid() != true )
{
return EXIT_FAILURE;
}

/* Create logging task */
xLoggingTaskInitialize( appCONFIG_LOGGING_TASK_STACK_SIZE,
appCONFIG_LOGGING_TASK_PRIORITY,
Expand Down
Loading