Skip to content

Commit

Permalink
Fix PKCS12 API Name (#601)
Browse files Browse the repository at this point in the history
* rename pkcs12 constructor

* mark old function as deprecated

* fix format
  • Loading branch information
xiazhvera authored Dec 4, 2024
1 parent bc6b5b0 commit cd3c976
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion documents/MQTT5_Userguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ A MQTT5 direct connection can be made using a PKCS12 file rather than using a PE
~~~ java

String clientEndpoint = "<prefix>-ats.iot.<region>.amazonaws.com";
AwsIotMqtt5ClientBuilder builder = AwsIotMqtt5ClientBuilder.newDirectMqttBuilderWithMtlsFromPkcs11(clientEndpoint, "<PKCS12 file path>", "<PKCS12 password>");
AwsIotMqtt5ClientBuilder builder = AwsIotMqtt5ClientBuilder.newDirectMqttBuilderWithMtlsFromPkcs12(clientEndpoint, "<PKCS12 file path>", "<PKCS12 password>");
~~~

**Note**: Currently, TLS integration with PKCS12 is only available on MacOS devices.
Expand Down
2 changes: 1 addition & 1 deletion samples/Mqtt5/PubSub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ A MQTT5 direct connection can be made using a PKCS12 file rather than using a PE
~~~ java

String clientEndpoint = "<prefix>-ats.iot.<region>.amazonaws.com";
AwsIotMqtt5ClientBuilder builder = AwsIotMqtt5ClientBuilder.newDirectMqttBuilderWithMtlsFromPkcs11(clientEndpoint, "<PKCS12 file path>", "<PKCS12 password>");
AwsIotMqtt5ClientBuilder builder = AwsIotMqtt5ClientBuilder.newDirectMqttBuilderWithMtlsFromPkcs12(clientEndpoint, "<PKCS12 file path>", "<PKCS12 password>");
~~~

**Note**: Currently, TLS integration with PKCS12 is only available on MacOS devices.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public static AwsIotMqtt5ClientBuilder newDirectMqttBuilderWithCustomAuth(String
}

/**
* @deprecated Use alternate newDirectMqttBuilderWithMtlsFromPkcs12().
* Create a new builder with mTLS, using a PKCS12 library for private key operations.
*
* NOTE: MacOS only
Expand All @@ -187,7 +188,23 @@ public static AwsIotMqtt5ClientBuilder newDirectMqttBuilderWithCustomAuth(String
* @param pkcs12Password The password of the PKCS12 file to use with the builder.
* @return - A new AwsIotMqtt5ClientBuilder
*/
@Deprecated
public static AwsIotMqtt5ClientBuilder newDirectMqttBuilderWithMtlsFromPkcs11(String hostName, String pkcs12Path, String pkcs12Password) {
return newDirectMqttBuilderWithMtlsFromPkcs12(hostName, pkcs12Path, pkcs12Password);
}


/**
* Create a new builder with mTLS, using a PKCS12 library for private key operations.
*
* NOTE: MacOS only
*
* @param hostName - AWS IoT endpoint to connect to
* @param pkcs12Path Path to the PKCS12 file to use with the builder.
* @param pkcs12Password The password of the PKCS12 file to use with the builder.
* @return - A new AwsIotMqtt5ClientBuilder
*/
public static AwsIotMqtt5ClientBuilder newDirectMqttBuilderWithMtlsFromPkcs12(String hostName, String pkcs12Path, String pkcs12Password) {
TlsContextOptions options = TlsContextOptions.createWithMtlsPkcs12(pkcs12Path, pkcs12Password);
AwsIotMqtt5ClientBuilder builder = new AwsIotMqtt5ClientBuilder(hostName, DEFAULT_DIRECT_MQTT_PORT, options);
options.close();
Expand Down

0 comments on commit cd3c976

Please sign in to comment.