1
1
# Sample apps for the AWS IoT Device SDK v2 for Python
2
2
3
3
* [ PubSub] ( #pubsub )
4
- * [ PKCS #11 PubSub] ( #pkcs11-pubsub )
5
- * [ Windows Certificate PubSub] ( #windows-certificate-pubsub )
4
+ * [ Basic Connect] ( #basic-connect )
5
+ * [ Websocket Connect] ( #websocket-connect )
6
+ * [ PKCS #11 Connect] ( #pkcs11-connect )
7
+ * [ Windows Certificate Connect] ( #windows-certificate-connect )
6
8
* [ Shadow] ( #shadow )
7
9
* [ Jobs] ( #jobs )
8
10
* [ Fleet Provisioning] ( #fleet-provisioning )
@@ -156,7 +158,7 @@ python3 websocket_connect.py --endpoint <endpoint> --ca_file <file> --signing_re
156
158
157
159
Note that using Websockets will attempt to fetch the AWS credentials from your enviornment variables or local files. See the [ authorizing direct AWS] ( https://docs.aws.amazon.com/iot/latest/developerguide/authorizing-direct-aws.html ) page for documentation on how to get the AWS credentials, which then you can set to the ` AWS_ACCESS_KEY_ID ` , ` AWS_SECRET_ACCESS ` , and ` AWS_SESSION_TOKEN ` environment variables.
158
160
159
- ## PKCS #11 PubSub
161
+ ## PKCS #11 Connect
160
162
161
163
This sample is similar to the [ Basic Connect] ( #basic-connect ) ,
162
164
but the private key for mutual TLS is stored on a PKCS #11 compatible smart card or Hardware Security Module (HSM)
@@ -165,6 +167,31 @@ WARNING: Unix only. Currently, TLS integration with PKCS#11 is only available on
165
167
166
168
source: ` samples/pkcs11_connect.py `
167
169
170
+ Your Thing's
171
+ [ Policy] ( https://docs.aws.amazon.com/iot/latest/developerguide/iot-policies.html )
172
+ must provide privileges for this sample to connect, subscribe, publish,
173
+ and receive.
174
+
175
+ <details >
176
+ <summary >(see sample policy)</summary >
177
+ <pre >
178
+ {
179
+ "Version": "2012-10-17",
180
+ "Statement": [
181
+ {
182
+ "Effect": "Allow",
183
+ "Action": [
184
+ "iot:Connect"
185
+ ],
186
+ "Resource": [
187
+ "arn:aws:iot:<b >region</b >:<b >account</b >:client/test-*"
188
+ ]
189
+ }
190
+ ]
191
+ }
192
+ </pre >
193
+ </details >
194
+
168
195
To run this sample using [ SoftHSM2] ( https://www.opendnssec.org/softhsm/ ) as the PKCS #11 device:
169
196
170
197
1 ) Create an IoT Thing with a certificate and key if you haven't already.
@@ -209,11 +236,11 @@ To run this sample using [SoftHSM2](https://www.opendnssec.org/softhsm/) as the
209
236
python3 pkcs11_connect.py --endpoint <xxxx-ats.iot.xxxx.amazonaws.com> --ca_file <AmazonRootCA1.pem> --cert <certificate.pem.crt> --pkcs11_lib <libsofthsm2.so> --pin <user-pin> --token_label <token-label> --key_label <key-label>
210
237
```
211
238
212
- ## Windows Certificate PubSub
239
+ ## Windows Certificate Connect
213
240
214
241
WARNING: Windows only
215
242
216
- This sample is similar to the basic [PubSub ](#pubsub ),
243
+ This sample is similar to the basic [Connect ](#basic-connect ),
217
244
but your certificate and private key are in a
218
245
[Windows certificate store](https://docs.microsoft.com/en-us/windows-hardware/drivers/install/certificate-stores),
219
246
rather than simply being files on disk.
@@ -227,7 +254,32 @@ If your certificate and private key are in a
227
254
[TPM](https://docs.microsoft.com/en-us/windows/security/information-protection/tpm/trusted-platform-module-overview),,
228
255
you would use them by passing their certificate store path.
229
256
230
- source: ` samples/windows_cert_pubsub.py`
257
+ source: ` samples/windows_cert_connect.py`
258
+
259
+ Your Thing' s
260
+ [Policy](https://docs.aws.amazon.com/iot/latest/developerguide/iot-policies.html)
261
+ must provide privileges for this sample to connect, subscribe, publish,
262
+ and receive.
263
+
264
+ <details>
265
+ <summary>(see sample policy)</summary>
266
+ <pre>
267
+ {
268
+ "Version": "2012-10-17",
269
+ "Statement": [
270
+ {
271
+ "Effect": "Allow",
272
+ "Action": [
273
+ "iot:Connect"
274
+ ],
275
+ "Resource": [
276
+ "arn:aws:iot:<b>region</b>:<b>account</b>:client/test-*"
277
+ ]
278
+ }
279
+ ]
280
+ }
281
+ </pre>
282
+ </details>
231
283
232
284
To run this sample with a basic certificate from AWS IoT Core:
233
285
@@ -269,7 +321,7 @@ To run this sample with a basic certificate from AWS IoT Core:
269
321
4) Now you can run the sample:
270
322
271
323
```sh
272
- python3 windows_cert_pubsub .py --endpoint xxxx-ats.iot.xxxx.amazonaws.com --root-ca AmazonRootCA.pem --cert CurrentUser\M y\A 11F8A9B5DF5B98BA3508FBCA575D09570E0D2C6
324
+ python3 windows_cert_connect .py --endpoint xxxx-ats.iot.xxxx.amazonaws.com --ca_file AmazonRootCA.pem --cert CurrentUser\My\A11F8A9B5DF5B98BA3508FBCA575D09570E0D2C6
273
325
```
274
326
275
327
## Shadow
0 commit comments