Skip to content

Commit 3d60611

Browse files
authored
[patch] add caFile: '_os_' as a way to use OS/python truststore (#214)
Co-authored-by: Jon Levell <[email protected]>
1 parent 592368c commit 3d60611

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

docs/application/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Application configuration can be broken down into required and optional configur
1717
- `options.mqtt.cleanStart` A boolean value indicating whether to discard any previous state when reconnecting to the service. Defaults to `False`.
1818
- `options.mqtt.sessionExpiry` When cleanStart is disabled, defines the maximum age of the previous session (in seconds). Defaults to `False`.
1919
- `options.mqtt.keepAlive` Control the frequency of MQTT keep alive packets (in seconds). Details to `60`.
20-
- `options.mqtt.caFile` A String value indicating the path to a CA file (in pem format) to use in verifying the server certificate. Defaults to `messaging.pem` inside this module.
20+
- `options.mqtt.caFile` A String value indicating the path to a CA file (in pem format) to use in verifying the server certificate. Defaults to `messaging.pem` inside this module. Use the special string `"_os_"` to use default python/OS truststore.
2121

2222

2323
The config parameter when constructing an instance of `wiotp.sdk.application.ApplicationClient` expects to be passed a dictionary containing this configuration:

docs/device/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Device configuration can be broken down into required and optional configuration
1616
- `options.mqtt.cleanStart` A boolean value indicating whether to discard any previous state when reconnecting to the service. Defaults to `False`.
1717
- `options.mqtt.sessionExpiry` When cleanStart is disabled, defines the maximum age of the previous session (in seconds). Defaults to `False`.
1818
- `options.mqtt.keepAlive` Control the frequency of MQTT keep alive packets (in seconds). Details to `60`.
19-
- `options.mqtt.caFile` A String value indicating the path to a CA file (in pem format) to use in verifying the server certificate. Defaults to `messaging.pem` inside this module.
19+
- `options.mqtt.caFile` A String value indicating the path to a CA file (in pem format) to use in verifying the server certificate. Defaults to `messaging.pem` inside this module. Use the special string `"_os_"` to use default python/OS truststore.
2020

2121

2222
The config parameter when constructing an instance of `wiotp.sdk.device.DeviceClient` expects to be passed a dictionary containing this configuration:

docs/gateway/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Gateway configuration can be broken down into required and optional configuratio
1616
- `options.mqtt.cleanStart` A boolean value indicating whether to discard any previous state when reconnecting to the service. Defaults to `False`.
1717
- `options.mqtt.sessionExpiry` When cleanStart is disabled, defines the maximum age of the previous session (in seconds). Defaults to `False`.
1818
- `options.mqtt.keepAlive` Control the frequency of MQTT keep alive packets (in seconds). Details to `60`.
19-
- `options.mqtt.caFile` A String value indicating the path to a CA file (in pem format) to use in verifying the server certificate. Defaults to `messaging.pem` inside this module.
19+
- `options.mqtt.caFile` A String value indicating the path to a CA file (in pem format) to use in verifying the server certificate. Defaults to `messaging.pem` inside this module. Use the special string `"_os_"` to use default python/OS truststore.
2020

2121

2222
The config parameter when constructing an instance of `wiotp.sdk.gateway.GatewayClient` expects to be passed a dictionary containing this configuration:

src/wiotp/sdk/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ def __init__(
176176
# Path to default CA certificate if none provided
177177
if caFile is None:
178178
caFile = os.path.dirname(os.path.abspath(__file__)) + "/messaging.pem"
179+
elif caFile == "_os_":
180+
self.logger.debug("Using OS trust store for certification verification")
181+
caFile=None
179182

180183
self.client.tls_set(
181184
ca_certs=caFile,

0 commit comments

Comments
 (0)