Skip to content

Commit d611867

Browse files
committed
update error print for DDTestRun, remove ca_file
1 parent 7f974ec commit d611867

18 files changed

Lines changed: 16 additions & 153 deletions

File tree

devicedefender/script/DDTestRun.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def delete_thing_with_certi(thingName, certiId, certiArn):
242242
arguments = [exe_path, "--endpoint", endpoint_response, "--cert",
243243
certificate_path, "--key", key_path, "--thing_name", thing_name, "--count", "2"]
244244
result = subprocess.run(arguments, timeout=60*2, check=True)
245-
print("[Device Defender]Info: Sample finished running.")
245+
print(f"[Device Defender]Info: Sample finished running, with result {result.returncode}")
246246

247247
# There does not appear to be any way to get the metrics from the device - so we'll assume that if it didn't return -1, then it worked
248248

@@ -264,7 +264,7 @@ def delete_thing_with_certi(thingName, certiId, certiArn):
264264
if client_made_policy:
265265
client.delete_policy(policyName=thing_name + "_policy")
266266

267-
print("[Device Defender]Error: Failed to test: Basic Report")
267+
print(f"[Device Defender]Error: Failed to test: Basic Report {e}")
268268
exit(-1)
269269

270270
print("[Device Defender]Info: Basic Report sample test passed")

samples/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ required arguments:
118118
--key Path to the private key file to use during mTLS connection establishment
119119
optional arguments:
120120
--client_id Client ID (default: mqtt5-sample-<uuid>)
121-
--ca_file Path to optional CA bundle (PEM)
122121
--topic Topic (default: test/topic)
123122
--message Message payload (default: Hello from mqtt5 sample)
124123
--count Messages to publish (0 = infinite) (default: 5)

samples/greengrass/basic_discovery/main.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ struct CmdArgs
2323
String endpoint;
2424
String cert;
2525
String key;
26-
String caFile;
2726
String thingName;
2827
String topic = "test/topic";
2928
String message;
@@ -157,7 +156,6 @@ void printHelp()
157156
printf(" --thing_name Thing name\n");
158157
printf("optional arguments:\n");
159158
printf(" --client_id Client ID (default: test-<uuid>)\n");
160-
printf(" --ca_file Path to optional CA bundle (PEM)\n");
161159
printf(" --topic Topic (default: test/topic)\n");
162160
printf(" --message Message to publish\n");
163161
printf(" --mode Mode: publish, subscribe, both (default: both)\n");
@@ -191,10 +189,7 @@ CmdArgs parseArgs(int argc, char *argv[])
191189
{
192190
args.thingName = argv[++i];
193191
}
194-
else if (strcmp(argv[i], "--ca_file") == 0)
195-
{
196-
args.caFile = argv[++i];
197-
}
192+
198193
else if (strcmp(argv[i], "--topic") == 0)
199194
{
200195
args.topic = argv[++i];
@@ -260,11 +255,6 @@ int main(int argc, char *argv[])
260255
exit(-1);
261256
}
262257

263-
if (!cmdData.caFile.empty())
264-
{
265-
tlsCtxOptions.OverrideDefaultTrustStore(nullptr, cmdData.caFile.c_str());
266-
}
267-
268258
Io::TlsContext tlsCtx(tlsCtxOptions, Io::TlsMode::CLIENT);
269259

270260
if (!tlsCtx)

samples/mqtt/mqtt5_aws_websocket/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ required arguments:
104104
105105
optional arguments:
106106
--client_id Client ID (default: mqtt5-sample-<uuid>)
107-
--ca_file Path to optional CA bundle (PEM)
108107
--topic Topic (default: test/topic)
109108
--message Message payload (default: Hello from mqtt5 sample)
110109
--count Messages to publish (0 = infinite) (default: 5)

samples/mqtt/mqtt5_aws_websocket/main.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ struct CmdArgs
1818
String endpoint;
1919
String signingRegion;
2020
String clientId;
21-
String caFile;
2221
String topic = "test/topic";
2322
String message = "Hello from mqtt5 sample";
2423
uint32_t count = 5;
@@ -37,7 +36,6 @@ void printHelp()
3736
printf("\n");
3837
printf("optional arguments:\n");
3938
printf(" --client_id Client ID (default: mqtt5-sample-<uuid>)\n");
40-
printf(" --ca_file Path to optional CA bundle (PEM)\n");
4139
printf(" --topic Topic (default: test/topic)\n");
4240
printf(" --message Message payload (default: Hello from mqtt5 sample)\n");
4341
printf(" --count Messages to publish (0 = infinite) (default: 5)\n");
@@ -63,10 +61,7 @@ CmdArgs parseArgs(int argc, char *argv[])
6361
{
6462
args.signingRegion = argv[++i];
6563
}
66-
else if (strcmp(argv[i], "--ca_file") == 0)
67-
{
68-
args.caFile = argv[++i];
69-
}
64+
7065
else if (strcmp(argv[i], "--client_id") == 0)
7166
{
7267
args.clientId = argv[++i];
@@ -151,12 +146,6 @@ int main(int argc, char *argv[])
151146
exit(1);
152147
}
153148

154-
// Setup CA file if provided
155-
if (!cmdData.caFile.empty())
156-
{
157-
builder->WithCertificateAuthority(cmdData.caFile.c_str());
158-
}
159-
160149
// Setup connection options
161150
std::shared_ptr<Mqtt5::ConnectPacket> connectOptions =
162151
Aws::Crt::MakeShared<Mqtt5::ConnectPacket>(Aws::Crt::DefaultAllocatorImplementation());

samples/mqtt/mqtt5_pkcs11/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ optional arguments:
116116
--token_label Label of the PKCS#11 token to use (optional). (default: None)
117117
--slot_id Slot ID containing the PKCS#11 token to use (optional). (default: None)
118118
--key_label Label of private key on the PKCS#11 token (optional). (default: None)
119-
--ca_file Path to optional CA bundle (PEM) (default: None)
120119
--topic Topic (default: test/topic)
121120
--message Message payload (default: Hello from mqtt5 sample)
122121
--count Messages to publish (0 = infinite) (default: 5)
@@ -176,8 +175,7 @@ The steps to use [SoftHSM2](https://www.opendnssec.org/softhsm/) as the PKCS#11
176175
6. Now you can run the sample with the following:
177176

178177
```sh
179-
# For Windows: replace 'python3' with 'python' and '/' with '\'
180-
python3 mqtt5_pkcs11_connect.py --endpoint <endpoint> --ca_file <path to root CA> --cert <path to certificate> --pkcs11_lib <path to PKCS11 lib> --pin <user-pin> --token_label <token-label> --key_label <key-label>
178+
./mqtt5_pkcs11 --endpoint <endpoint> --cert <path to certificate> --pkcs11_lib <path to PKCS11 lib> --pin <user-pin> --token_label <token-label> --key_label <key-label>
181179
```
182180

183181
## Additional Information

samples/mqtt/mqtt5_pkcs11/main.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ struct CmdArgs
2222
String pkcs11TokenLabel;
2323
String pkcs11KeyLabel;
2424
String clientId;
25-
String caFile;
2625
String topic = "test/topic";
2726
String message = "Hello from mqtt5 sample";
2827
uint32_t port = 8883;
@@ -50,7 +49,6 @@ void printHelp()
5049
printf(" --token_label Label of the PKCS#11 token to use\n");
5150
printf(" --slot_id Slot ID containing the PKCS#11 token to use\n");
5251
printf(" --key_label Label of private key on the PKCS#11 token\n");
53-
printf(" --ca_file Path to optional CA bundle (PEM)\n");
5452
printf(" --topic Topic (default: test/topic)\n");
5553
printf(" --message Message payload (default: Hello from mqtt5 sample)\n");
5654
printf(" --count Messages to publish (0 = infinite) (default: 5)\n");
@@ -98,10 +96,7 @@ CmdArgs parseArgs(int argc, char *argv[])
9896
{
9997
args.pkcs11KeyLabel = argv[++i];
10098
}
101-
else if (strcmp(argv[i], "--ca_file") == 0)
102-
{
103-
args.caFile = argv[++i];
104-
}
99+
105100
else if (strcmp(argv[i], "--client_id") == 0)
106101
{
107102
args.clientId = argv[++i];
@@ -210,12 +205,6 @@ int main(int argc, char *argv[])
210205

211206
// Setup port if not default
212207
builder->WithPort(cmdData.port);
213-
214-
// Setup CA file if provided
215-
if (!cmdData.caFile.empty())
216-
{
217-
builder->WithCertificateAuthority(cmdData.caFile.c_str());
218-
}
219208

220209
// Setup connection options
221210
std::shared_ptr<Mqtt5::ConnectPacket> connectOptions =

samples/mqtt/mqtt5_x509/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ required arguments:
101101
--key Path to the private key file to use during mTLS connection establishment
102102
optional arguments:
103103
--client_id Client ID (default: mqtt5-sample-<uuid>)
104-
--ca_file Path to optional CA bundle (PEM)
105104
--topic Topic (default: test/topic)
106105
--message Message payload (default: Hello from mqtt5 sample)
107106
--count Messages to publish (0 = infinite) (default: 5)

samples/mqtt/mqtt5_x509/main.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ struct CmdArgs
1818
String cert;
1919
String key;
2020
String clientId;
21-
String caFile;
2221
String topic = "test/topic";
2322
String message = "Hello from mqtt5 sample";
2423
uint32_t count = 5;
@@ -37,7 +36,6 @@ void printHelp()
3736
" --key Path to the private key file to use during mTLS connection establishment\n");
3837
printf("optional arguments:\n");
3938
printf(" --client_id Client ID (default: mqtt5-sample-<uuid>)\n");
40-
printf(" --ca_file Path to optional CA bundle (PEM)\n");
4139
printf(" --topic Topic (default: test/topic)\n");
4240
printf(" --message Message payload (default: Hello from mqtt5 sample)\n");
4341
printf(" --count Messages to publish (0 = infinite) (default: 5)\n");
@@ -67,10 +65,7 @@ CmdArgs parseArgs(int argc, char *argv[])
6765
{
6866
args.key = argv[++i];
6967
}
70-
else if (strcmp(argv[i], "--ca_file") == 0)
71-
{
72-
args.caFile = argv[++i];
73-
}
68+
7469
else if (strcmp(argv[i], "--client_id") == 0)
7570
{
7671
args.clientId = argv[++i];
@@ -143,12 +138,6 @@ int main(int argc, char *argv[])
143138
exit(1);
144139
}
145140

146-
// Setup CA file if provided
147-
if (!cmdData.caFile.empty())
148-
{
149-
builder->WithCertificateAuthority(cmdData.caFile.c_str());
150-
}
151-
152141
// Setup connection options
153142
std::shared_ptr<Mqtt5::ConnectPacket> connectOptions =
154143
Aws::Crt::MakeShared<Mqtt5::ConnectPacket>(Aws::Crt::DefaultAllocatorImplementation());

samples/others/device_defender/mqtt5_basic_report/README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,7 @@ This sample expects and requires the following custom metrics:
6666
To run the Device Defender sample, use the following command:
6767

6868
``` sh
69-
./mqtt5-basic-report --endpoint <endpoint> --cert <path to the certificate> --key <path to the private key> --thing_name <thing name> --ca_file <path to root CA>
70-
```
71-
72-
You can also pass a Certificate Authority file (CA) if your certificate and key combination requires it:
73-
74-
``` sh
75-
./mqtt5-basic-report --endpoint <endpoint> --cert <path to the certificate> --key <path to the private key> --thing_name <thing name> --ca_file <path to root CA>
69+
./mqtt5-basic-report --endpoint <endpoint> --cert <path to the certificate> --key <path to the private key> --thing_name <thing name>
7670
```
7771

7872
### Device Defender Data Requirements

0 commit comments

Comments
 (0)