mirror of
https://github.com/espressif/openthread.git
synced 2026-06-06 05:24:51 +00:00
[tcat] Fix handling certificate path in tcat client. (#10597)
Commit fixes propagation of certificate path from `cert-path` option to `scan` command.
This commit is contained in:
committed by
Jonathan Hui
parent
c36c0ed760
commit
12cf1207d2
@@ -96,7 +96,7 @@ async def main():
|
||||
quit_with_reason('TLS handshake failure')
|
||||
|
||||
ds = ThreadDataset()
|
||||
cli = CLI(ds, ble_sstream)
|
||||
cli = CLI(ds, args, ble_sstream)
|
||||
loop = asyncio.get_running_loop()
|
||||
print('Enter \'help\' to see available commands' ' or \'exit\' to exit the application.')
|
||||
while True:
|
||||
|
||||
@@ -251,10 +251,11 @@ class ScanCommand(Command):
|
||||
print(f'Connecting to {device}')
|
||||
ble_stream = await BleStream.create(device.address, BBTC_SERVICE_UUID, BBTC_TX_CHAR_UUID, BBTC_RX_CHAR_UUID)
|
||||
ble_sstream = BleStreamSecure(ble_stream)
|
||||
cert_path = context['cmd_args'].cert_path if context['cmd_args'] else 'auth'
|
||||
ble_sstream.load_cert(
|
||||
certfile=path.join('auth', 'commissioner_cert.pem'),
|
||||
keyfile=path.join('auth', 'commissioner_key.pem'),
|
||||
cafile=path.join('auth', 'ca_cert.pem'),
|
||||
certfile=path.join(cert_path, 'commissioner_cert.pem'),
|
||||
keyfile=path.join(cert_path, 'commissioner_key.pem'),
|
||||
cafile=path.join(cert_path, 'ca_cert.pem'),
|
||||
)
|
||||
|
||||
print('Setting up secure channel...')
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
"""
|
||||
|
||||
import readline
|
||||
import shlex
|
||||
from argparse import ArgumentParser
|
||||
from ble.ble_stream_secure import BleStreamSecure
|
||||
from cli.base_commands import (HelpCommand, HelloCommand, CommissionCommand, DecommissionCommand, GetDeviceIdCommand,
|
||||
GetExtPanIDCommand, GetNetworkNameCommand, GetProvisioningUrlCommand, PingCommand,
|
||||
@@ -39,7 +39,10 @@ from typing import Optional
|
||||
|
||||
class CLI:
|
||||
|
||||
def __init__(self, dataset: ThreadDataset, ble_sstream: Optional[BleStreamSecure] = None):
|
||||
def __init__(self,
|
||||
dataset: ThreadDataset,
|
||||
cmd_args: Optional[ArgumentParser] = None,
|
||||
ble_sstream: Optional[BleStreamSecure] = None):
|
||||
self._commands = {
|
||||
'help': HelpCommand(),
|
||||
'hello': HelloCommand(),
|
||||
@@ -54,7 +57,12 @@ class CLI:
|
||||
'thread': ThreadStateCommand(),
|
||||
'scan': ScanCommand(),
|
||||
}
|
||||
self._context = {'ble_sstream': ble_sstream, 'dataset': dataset, 'commands': self._commands}
|
||||
self._context = {
|
||||
'ble_sstream': ble_sstream,
|
||||
'dataset': dataset,
|
||||
'commands': self._commands,
|
||||
'cmd_args': cmd_args
|
||||
}
|
||||
readline.set_completer(self.completer)
|
||||
readline.parse_and_bind('tab: complete')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user