|
| 1 | +# ------------------------------------------------------------------------- |
| 2 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | +# Licensed under the MIT License. See License.txt in the project root for |
| 4 | +# license information. |
| 5 | +# -------------------------------------------------------------------------- |
| 6 | + |
| 7 | +## SCENARIO |
| 8 | + |
| 9 | +Connect to an IoT hub using TLS 1.3 (currently in preview) and then periodically send telemetry messages. |
| 10 | + |
| 11 | +## CONTEXT |
| 12 | + |
| 13 | +### IoT hub support for TLS 1.3 |
| 14 | +IoT Hub is currently previewing the ability to use TLS 1.3, but accessing that requires some small changes on the client side. |
| 15 | + |
| 16 | +Up until now, connection strings would always follow a format like: |
| 17 | + |
| 18 | +``` |
| 19 | +<hub name>.azure-devices.<dnsSuffix> |
| 20 | +``` |
| 21 | + |
| 22 | +and this IoT hub endpoint supports TLS versions 1.0, 1.1, and 1.2 |
| 23 | + |
| 24 | +IoT hub is previewing offering TLS version 1.2 + 1.3 support in endpoints with connection strings like |
| 25 | + |
| 26 | +``` |
| 27 | +device connection string: |
| 28 | +<hub name>.device.azure-devices.<dnsSuffix> |
| 29 | +``` |
| 30 | + |
| 31 | +and |
| 32 | + |
| 33 | +``` |
| 34 | +service connection string: |
| 35 | +<hub name>.service.azure-devices.<dnsSuffix> |
| 36 | +``` |
| 37 | + |
| 38 | +This sample expects the environment variable "IOTHUB_DEVICE_CONNECTION_STRING" to contain a connection string that follows the device connection string pattern above |
| 39 | + |
| 40 | +### SDK behavior |
| 41 | + |
| 42 | +When you run this sample, the "Client Hello" message in the TLS layer will advertise to IoT hub that this client supports TLS 1.2 and TLS 1.3. In the "Server Hello" response, IoT hub will then choose TLS 1.3 as the version for both client and server to use for this connection. |
| 43 | + |
| 44 | +Note that the SDK behavior here is unchanged as it has always advertised support for TLS 1.2 and TLS 1.3. The only change to make the connection use TLS 1.3 is to connect with the connection string of the host that also supports TLS 1.3 |
| 45 | + |
| 46 | +## ADDITIONAL CONSIDERATIONS |
| 47 | + |
| 48 | +This feature is not generally available yet nor is it available in preview for all IoT hubs. As such, the above connection string pattern my yield a "host not found" exception. |
| 49 | + |
| 50 | +Note that this library currently uses the SSL library for all TLS connections. This SSL library has a few feature gaps around TLS 1.3 specifically as documented [here](https://docs.python.org/3/library/ssl.html#tls-1-3) |
0 commit comments