Skip to content

Commit

Permalink
Merge pull request #354 from gojimmypi/WOLFMQTT_EXAMPLE_CERT
Browse files Browse the repository at this point in the history
WOLFMQTT_EXAMPLE_CERT allowing static or extern cert assignment
  • Loading branch information
embhorn committed Dec 15, 2023
2 parents 15ba2f2 + 620470b commit c98d9ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/aws/awsiot.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static int mTestDone = 0;
#define AWSIOT_PUBLISH_MSG_SZ 400

/* Demo Certificates */
static const char* root_ca =
WOLFMQTT_EXAMPLE_CERT const char* root_ca =
"-----BEGIN CERTIFICATE-----\n"
"MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB\n"
"yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL\n"
Expand Down Expand Up @@ -120,7 +120,7 @@ static const char* device_pub_key =
"-----END PUBLIC KEY-----";
#endif

static const char* device_priv_key =
WOLFMQTT_EXAMPLE_CERT const char* device_priv_key =
#ifndef WOLFSSL_ENCRYPTED_KEYS
"-----BEGIN RSA PRIVATE KEY-----\n"
"MIIEpAIBAAKCAQEAqsAKVhbfQEWblC8PvgubqpJasVoCEsSfvLF4b5DIAsoMeieP\n"
Expand Down Expand Up @@ -182,7 +182,7 @@ static const char* device_priv_key =
"-----END ENCRYPTED PRIVATE KEY-----";
#endif

static const char* device_cert =
WOLFMQTT_EXAMPLE_CERT const char* device_cert =
"-----BEGIN CERTIFICATE-----\n"
"MIIDWjCCAkKgAwIBAgIVANIzUucLFUREa2BiJUXoRv6Z4XaIMA0GCSqGSIb3DQEB\n"
"CwUAME0xSzBJBgNVBAsMQkFtYXpvbiBXZWIgU2VydmljZXMgTz1BbWF6b24uY29t\n"
Expand Down
12 changes: 12 additions & 0 deletions examples/mqttexample.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@
#define DEFAULT_SESS_EXP_INT 0xFFFFFFFF
#endif

/* certs are either static or extern, depending on the specific example */
#ifdef WOLFMQTT_EXTERN_CERT
#undef WOLFMQTT_EXAMPLE_CERT
#define WOLFMQTT_EXAMPLE_CERT /* init extern from mqttexample.h */
extern const char* root_ca;
extern const char* device_cert;
extern const char* device_priv_key;
#else
#undef WOLFMQTT_EXAMPLE_CERT
#define WOLFMQTT_EXAMPLE_CERT static
#endif

/* MQTT Client state */
typedef enum _MQTTCtxState {
WMQ_BEGIN = 0,
Expand Down

0 comments on commit c98d9ab

Please sign in to comment.