@@ -910,34 +910,54 @@ STATUS lookForSslCert(PSampleConfiguration* ppSampleConfiguration)
910
910
}
911
911
912
912
STATUS createSampleConfiguration (PCHAR channelName , SIGNALING_CHANNEL_ROLE_TYPE roleType , BOOL trickleIce , BOOL useTurn , UINT32 logLevel ,
913
- PSampleConfiguration * ppSampleConfiguration )
913
+ PAwsCredentialOptions pAwsCredentialOptions , PSampleConfiguration * ppSampleConfiguration )
914
914
{
915
915
STATUS retStatus = STATUS_SUCCESS ;
916
916
PSampleConfiguration pSampleConfiguration = NULL ;
917
+ PCHAR pAccessKey = NULL , pSecretKey = NULL , pSessionToken = NULL ;
918
+ PCHAR pIotCoreCredentialEndPoint = NULL , pIotCoreCert = NULL , pIotCorePrivateKey = NULL ;
919
+ PCHAR pIotCoreRoleAlias = NULL , pIotCoreCertificateId = NULL , pIotCoreThingName = NULL ;
917
920
918
921
CHK (ppSampleConfiguration != NULL , STATUS_NULL_ARG );
919
922
920
923
CHK (NULL != (pSampleConfiguration = (PSampleConfiguration ) MEMCALLOC (1 , SIZEOF (SampleConfiguration ))), STATUS_NOT_ENOUGH_MEMORY );
921
924
922
- #ifdef CONFIG_IOT_CORE_ENABLE_CREDENTIALS
923
- PCHAR pIotCoreCredentialEndPoint , pIotCoreCert , pIotCorePrivateKey , pIotCoreRoleAlias , pIotCoreCertificateId , pIotCoreThingName ;
924
- CHK_ERR ((pIotCoreCredentialEndPoint = GETENV (IOT_CORE_CREDENTIAL_ENDPOINT )) != NULL , STATUS_INVALID_OPERATION ,
925
- "AWS_IOT_CORE_CREDENTIAL_ENDPOINT must be set" );
926
- CHK_ERR ((pIotCoreCert = GETENV (IOT_CORE_CERT )) != NULL , STATUS_INVALID_OPERATION , "AWS_IOT_CORE_CERT must be set" );
927
- CHK_ERR ((pIotCorePrivateKey = GETENV (IOT_CORE_PRIVATE_KEY )) != NULL , STATUS_INVALID_OPERATION , "AWS_IOT_CORE_PRIVATE_KEY must be set" );
928
- CHK_ERR ((pIotCoreRoleAlias = GETENV (IOT_CORE_ROLE_ALIAS )) != NULL , STATUS_INVALID_OPERATION , "AWS_IOT_CORE_ROLE_ALIAS must be set" );
929
- CHK_ERR ((pIotCoreThingName = GETENV (IOT_CORE_THING_NAME )) != NULL , STATUS_INVALID_OPERATION , "AWS_IOT_CORE_THING_NAME must be set" );
930
- #else
931
- PCHAR pAccessKey , pSecretKey , pSessionToken ;
932
- CHK_ERR ((pAccessKey = GETENV (ACCESS_KEY_ENV_VAR )) != NULL , STATUS_INVALID_OPERATION , "AWS_ACCESS_KEY_ID must be set" );
933
- CHK_ERR ((pSecretKey = GETENV (SECRET_KEY_ENV_VAR )) != NULL , STATUS_INVALID_OPERATION , "AWS_SECRET_ACCESS_KEY must be set" );
934
-
935
- pSessionToken = GETENV (SESSION_TOKEN_ENV_VAR );
936
- if (pSessionToken != NULL && IS_EMPTY_STRING (pSessionToken )) {
937
- DLOGW ("Session token is set but its value is empty. Ignoring." );
938
- pSessionToken = NULL ;
925
+ // Store the AWS credential options in the sample configuration
926
+ pSampleConfiguration -> pAwsCredentialOptions = pAwsCredentialOptions ;
927
+
928
+ if (pAwsCredentialOptions != NULL ) {
929
+ if (pAwsCredentialOptions -> enableIotCredentials ) {
930
+ // Use IoT Core credentials from the options
931
+ pIotCoreCredentialEndPoint = pAwsCredentialOptions -> iotCoreCredentialEndpoint ;
932
+ pIotCoreCert = pAwsCredentialOptions -> iotCoreCert ;
933
+ pIotCorePrivateKey = pAwsCredentialOptions -> iotCorePrivateKey ;
934
+ pIotCoreRoleAlias = pAwsCredentialOptions -> iotCoreRoleAlias ;
935
+ pIotCoreThingName = pAwsCredentialOptions -> iotCoreThingName ;
936
+ // Validate required fields
937
+ CHK_ERR (pIotCoreCredentialEndPoint != NULL && pIotCoreCredentialEndPoint [0 ] != '\0' , STATUS_INVALID_OPERATION ,
938
+ "IoT Core credential endpoint must be set" );
939
+ CHK_ERR (pIotCoreCert != NULL && pIotCoreCert [0 ] != '\0' , STATUS_INVALID_OPERATION ,
940
+ "IoT Core certificate must be set" );
941
+ CHK_ERR (pIotCorePrivateKey != NULL && pIotCorePrivateKey [0 ] != '\0' , STATUS_INVALID_OPERATION ,
942
+ "IoT Core private key must be set" );
943
+ CHK_ERR (pIotCoreRoleAlias != NULL && pIotCoreRoleAlias [0 ] != '\0' , STATUS_INVALID_OPERATION ,
944
+ "IoT Core role alias must be set" );
945
+ CHK_ERR (pIotCoreThingName != NULL && pIotCoreThingName [0 ] != '\0' , STATUS_INVALID_OPERATION ,
946
+ "IoT Core thing name must be set" );
947
+ } else {
948
+ // Use direct AWS credentials from the options
949
+ pAccessKey = pAwsCredentialOptions -> accessKey ;
950
+ pSecretKey = pAwsCredentialOptions -> secretKey ;
951
+ pSessionToken = pAwsCredentialOptions -> sessionToken ;
952
+ // Validate required fields
953
+ CHK_ERR (pAccessKey != NULL && pAccessKey [0 ] != '\0' , STATUS_INVALID_OPERATION ,
954
+ "AWS access key must be set" );
955
+ CHK_ERR (pSecretKey != NULL && pSecretKey [0 ] != '\0' , STATUS_INVALID_OPERATION ,
956
+ "AWS secret key must be set" );
957
+ }
958
+ } else {
959
+ DLOGI ("Streaming only mode, skipping credentials" );
939
960
}
940
- #endif
941
961
942
962
943
963
// If the env is set, we generate normal log files apart from filtered profile log files
@@ -969,13 +989,14 @@ STATUS createSampleConfiguration(PCHAR channelName, SIGNALING_CHANNEL_ROLE_TYPE
969
989
// CHK_STATUS(lookForSslCert(&pSampleConfiguration));
970
990
pSampleConfiguration -> pCaCertPath = DEFAULT_KVS_CACERT_PATH ;
971
991
972
- #ifdef CONFIG_IOT_CORE_ENABLE_CREDENTIALS
973
- CHK_STATUS (createIotCredentialProvider (pIotCoreCredentialEndPoint , pIotCoreCert , pIotCorePrivateKey , pSampleConfiguration -> pCaCertPath ,
974
- pIotCoreRoleAlias , pIotCoreThingName , & pSampleConfiguration -> pCredentialProvider ));
975
- #else
976
- CHK_STATUS (
977
- createStaticCredentialProvider (pAccessKey , 0 , pSecretKey , 0 , pSessionToken , 0 , MAX_UINT64 , & pSampleConfiguration -> pCredentialProvider ));
978
- #endif
992
+ if (pAwsCredentialOptions != NULL &&
993
+ pAwsCredentialOptions -> enableIotCredentials ) {
994
+ CHK_STATUS (createIotCredentialProvider (pIotCoreCredentialEndPoint , pIotCoreCert , pIotCorePrivateKey , pSampleConfiguration -> pCaCertPath ,
995
+ pIotCoreRoleAlias , pIotCoreThingName , & pSampleConfiguration -> pCredentialProvider ));
996
+ } else {
997
+ CHK_STATUS (
998
+ createStaticCredentialProvider (pAccessKey , 0 , pSecretKey , 0 , pSessionToken , 0 , MAX_UINT64 , & pSampleConfiguration -> pCredentialProvider ));
999
+ }
979
1000
980
1001
pSampleConfiguration -> mediaSenderTid = INVALID_TID_VALUE ;
981
1002
pSampleConfiguration -> audioSenderTid = INVALID_TID_VALUE ;
0 commit comments