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

WOLFMQTT_EXAMPLE_CERT allowing static or extern cert assignment #354

Merged
merged 4 commits into from
Dec 15, 2023
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
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
Loading