Skip to content

Commit d814bd4

Browse files
committed
update cert to cacert
1 parent cb3b806 commit d814bd4

15 files changed

Lines changed: 61 additions & 56 deletions

doc/getting_started.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -446,14 +446,14 @@ Refer to the ``labgrid-coordinator`` man page for details.
446446

447447
When you are connecting with ``labgrid-client`` or ``labgrid-exporter`` to a
448448
``labgrid-coordinator`` that has TLS gRPC channels enabled you need to pass
449-
the ``--tls`` option. If ``--cert`` is not set, labgrid uses the host CA
450-
certificates to verify the coordinator certificate. Use ``--cert`` to provide
451-
a specific CA certificate instead.
449+
the ``--tls`` option. If ``--cacert`` is not set, labgrid uses the host CA
450+
certificates to verify the coordinator certificate. Use ``--cacert`` to provide
451+
a specific CA certificate or CA bundle instead.
452452
Refer to the ``labgrid-client`` and ``labgrid-exporter`` man pages for details.
453453
For ``RemotePlace`` connections from an environment config, set the
454-
``coordinator_tls`` option or ``LG_COORDINATOR_TLS``. If ``coordinator_cert``
455-
is not set, labgrid uses the host CA certificates. Set ``coordinator_cert``
456-
to provide a specific CA certificate instead.
454+
``coordinator_tls`` option or ``LG_COORDINATOR_TLS``. If ``coordinator_cacert``
455+
is not set, labgrid uses the host CA certificates. Set ``coordinator_cacert``
456+
to provide a specific CA certificate or CA bundle instead.
457457

458458
Using a Strategy
459459
----------------

doc/man/client.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ Retrieve a list of places on a ``labgrid-coordinator`` that uses TLS gRPC channe
137137

138138
.. code-block:: bash
139139
140-
$ labgrid-client --tls [--cert PATH] places
140+
$ labgrid-client --tls [--cacert PATH] places
141141
142142
See Also
143143
--------

doc/man/coordinator.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ OPTIONS
2828
--tls
2929
enable TLS gRPC channel
3030
--cert
31-
path to TLS certificate (in PEM format)
31+
path to server TLS certificate (in PEM format)
3232
--key
3333
path to TLS key (in PEM format)
3434
-d, --debug

doc/man/device-config.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ OPTIONS KEYS
4747
enables a TLS gRPC channel for ``RemotePlace`` connections.
4848
Defaults to whether ``LG_COORDINATOR_TLS`` is set.
4949

50-
``coordinator_cert``
51-
path to the coordinator TLS certificate in PEM format for ``RemotePlace``
52-
connections. If unset, the host CA certificates are used. Relative paths are
53-
resolved relative to the configuration file.
50+
``coordinator_cacert``
51+
path to a CA certificate or CA bundle in PEM format for verifying the
52+
coordinator in ``RemotePlace`` connections. If unset, the host CA certificates
53+
are used. Relative paths are resolved relative to the configuration file.
5454

5555
.. _labgrid-device-config-images:
5656

doc/man/exporter.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ OPTIONS
2929
coordinator ``HOST[:PORT]`` to connect to, defaults to ``127.0.0.1:20408``
3030
--tls
3131
enable TLS gRPC channel
32-
--cert
33-
path to TLS certificate (in PEM format)
32+
--cacert
33+
path to CA certificate or CA bundle for verifying the coordinator (in PEM format)
3434
-i, --isolated
3535
enable isolated mode (always request SSH forwards)
3636
-n, --name
@@ -107,7 +107,7 @@ Same as above, but connecting to a ``labgrid-coordinator`` that uses TLS gRPC ch
107107

108108
.. code-block:: bash
109109
110-
$ labgrid-exporter --tls [--cert PATH] -n myname my-config.yaml
110+
$ labgrid-exporter --tls [--cacert PATH] -n myname my-config.yaml
111111
112112
SEE ALSO
113113
--------

labgrid/remote/client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1869,7 +1869,11 @@ def get_parser(auto_doc_mode=False) -> "argparse.ArgumentParser | AutoProgramArg
18691869
default=os.environ.get("LG_COORDINATOR_TLS") is not None,
18701870
help="enable TLS gRPC channel",
18711871
)
1872-
parser.add_argument("--cert", type=pathlib.PurePath, help="path to the server's TLS certificate (in PEM format)")
1872+
parser.add_argument(
1873+
"--cacert",
1874+
type=pathlib.PurePath,
1875+
help="path to CA certificate or CA bundle for verifying the coordinator (in PEM format)",
1876+
)
18731877
parser.add_argument(
18741878
"-c",
18751879
"--config",

labgrid/remote/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ def get_client_credentials(args: Namespace) -> Optional[grpc.ChannelCredentials]
108108
if not args.tls:
109109
return None
110110

111-
if not args.cert:
111+
if not args.cacert:
112112
return grpc.ssl_channel_credentials(root_certificates=_fetch_root_certificates())
113113

114-
with open(args.cert, "rb") as fc:
114+
with open(args.cacert, "rb") as fc:
115115
return grpc.ssl_channel_credentials(root_certificates=fc.read())
116116

117117

labgrid/remote/coordinator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ def main():
12041204
help="coordinator listening host and port",
12051205
)
12061206
parser.add_argument("--tls", action="store_true", default=False, help="enable TLS gRPC channel")
1207-
parser.add_argument("--cert", type=pathlib.PurePath, help="path to TLS certificate (in PEM format)")
1207+
parser.add_argument("--cert", type=pathlib.PurePath, help="path to server TLS certificate (in PEM format)")
12081208
parser.add_argument("--key", type=pathlib.PurePath, help="path to TLS key (in PEM format)")
12091209
parser.add_argument("-d", "--debug", action="store_true", default=False, help="enable debug mode")
12101210
parser.add_argument("--pystuck", action="store_true", help="enable pystuck")

labgrid/remote/exporter.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,11 @@ def main():
10931093
help="coordinator host and port",
10941094
)
10951095
parser.add_argument("--tls", action="store_true", default=False, help="enable TLS gRPC channel")
1096-
parser.add_argument("--cert", type=pathlib.PurePath, help="path to TLS certificate (in PEM format)")
1096+
parser.add_argument(
1097+
"--cacert",
1098+
type=pathlib.PurePath,
1099+
help="path to CA certificate or CA bundle for verifying the coordinator (in PEM format)",
1100+
)
10971101
parser.add_argument(
10981102
"-n",
10991103
"--name",

labgrid/resource/remote.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,29 @@ def __attrs_post_init__(self):
1717
self.ready = None
1818
self.unmanaged_resources = []
1919

20-
@staticmethod
21-
def _is_tls_option_enabled(value):
22-
if isinstance(value, str):
23-
return value.strip().lower() == "true"
24-
25-
return value is True
26-
2720
def _get_credentials(self):
2821
from ..remote.common import get_client_credentials
2922

3023
tls = os.environ.get("LG_COORDINATOR_TLS") is not None
31-
cert = None
24+
cacert = None
3225

3326
if self.env:
3427
config = self.env.config
3528
tls = config.get_option("coordinator_tls", tls)
29+
if isinstance(tls, str):
30+
tls = tls.strip().lower() == "true"
31+
else:
32+
tls = tls is True
3633

37-
cert = config.get_option("coordinator_cert", "")
38-
if cert:
39-
cert = config.resolve_path(str(cert))
34+
cacert = config.get_option("coordinator_cacert", "")
35+
if cacert:
36+
cacert = config.resolve_path(str(cacert))
4037
else:
41-
cert = None
38+
cacert = None
4239

4340
args = Namespace(
44-
tls=self._is_tls_option_enabled(tls),
45-
cert=cert,
41+
tls=tls,
42+
cacert=cacert,
4643
)
4744

4845
return get_client_credentials(args)

0 commit comments

Comments
 (0)