You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -171,6 +172,21 @@ A MQTT5 direct connection can be made using a PKCS11 device rather than using a
171
172
172
173
**Note**: Currently, TLS integration withPKCS#11 is only available on Unix devices.
173
174
175
+
#### **Direct MQTT with PKCS12 Method**
176
+
177
+
A MQTT5 direct connection can be made using a PKCS12file rather than using a PEM encoded private key. To create a MQTT5 builder configured for this connection, see the following code:
178
+
179
+
```python
180
+
# other builder configurations can be added using **kwargs in the builder
181
+
182
+
client= mqtt5_client_builder.mtls_with_pkcs12(
183
+
pkcs12_filepath="<PKCS12 file path>,
184
+
pkcs12_password="<PKCS12 password>
185
+
endpoint="<account-specific endpoint>")
186
+
```
187
+
188
+
**Note**: Currently, TLS integration withPKCS#12 is only available on MacOS devices.
189
+
174
190
#### **MQTT over Websockets with Cognito authentication**
175
191
176
192
A MQTT5 websocket connection can be made using Cognito to authenticate rather than the AWS credentials located on the device or via key and certificate. Instead, Cognito can authenticate the connection using a valid Cognito identity ID. This requires a valid Cognito identity ID, which can be retrieved from a Cognito identity pool. A Cognito identity pool can be created from the AWS console.
This sample is similar to the [Basic Connect](../BasicConnect/README.md) sample, in that it connects via Mutual TLS (mTLS) using a certificate and key file. However, unlike the Basic Connect where the certificate and private key file are stored on disk, this sample uses a PKCS#12 file instead.
6
+
7
+
**WARNING: MacOS only**. Currently, TLS integration with PKCS12 is only available on MacOS devices.
8
+
9
+
Your IoT Core Thing's [Policy](https://docs.aws.amazon.com/iot/latest/developerguide/iot-policies.html) must provide privileges for this sample to connect. Below is a sample policy that can be used on your IoT Core Thing that will allow this sample to run as intended.
Replace with the following with the data from your AWS account:
31
+
*`<region>`: The AWS IoT Core region where you created your AWS IoT Core thing you wish to use with this sample. For example `us-east-1`.
32
+
*`<account>`: Your AWS IoT Core account ID. This is the set of numbers in the top right next to your AWS account name when using the AWS IoT Core website.
33
+
34
+
Note that in a real application, you may want to avoid the use of wildcards in your ClientID or use them selectively. Please follow best practices when working with AWS on production applications using the SDK. Also, for the purposes of this sample, please make sure your policy allows a client ID of `test-*` to connect or use `--client_id <client ID here>` to send the client ID your policy supports.
35
+
36
+
</details>
37
+
38
+
## How to run
39
+
40
+
To run the PKCS12 connect use the following command:
41
+
42
+
```sh
43
+
python3 pkcs12_connect --endpoint <endpoint> --pkcs12_file <path to PKCS12 file> --pkcs12_password <password for PKCS12 file>
44
+
```
45
+
46
+
You can also pass a Certificate Authority file (CA) if your certificate and key combination requires it:
47
+
48
+
```sh
49
+
python3 pkcs12_connect --endpoint <endpoint> --pkcs12_file <path to PKCS12 file> --pkcs12_password <password for PKCS12 file> --ca_file <path to CA file>
50
+
```
51
+
52
+
### How to setup and run
53
+
54
+
To use the certificate and key files provided by AWS IoT Core, you will need to convert them into PKCS#12 format and then import them into your Java keystore. You can convert the certificate and key file to PKCS12 using the following command:
0 commit comments