Skip to content

Commit ed25464

Browse files
authored
Disable SSL by default (#85)
2 parents c632970 + 3e81e06 commit ed25464

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

.github/dependabot.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ updates:
2727
- "patch"
2828
exclude-patterns:
2929
- "frequenz-client-base*"
30-
- "frequenz-microgrid-betterproto*"
30+
- "frequenz-api-microgrid"
3131
optional:
3232
dependency-type: "development"
3333
update-types:
3434
- "minor"
3535
- "patch"
3636
exclude-patterns:
3737
- "frequenz-client-base*"
38-
- "frequenz-microgrid-betterproto*"
38+
- "frequenz-api-microgrid"
3939
in-devel-patch:
4040
patterns:
4141
- "frequenz-client-base*"
42-
- "frequenz-microgrid-betterproto*"
42+
- "frequenz-api-microgrid"
4343
dependency-type: "production"
4444
update-types:
4545
- "patch"

RELEASE_NOTES.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
# Frequenz Microgrid API Client Release Notes
22

3-
## Summary
4-
5-
<!-- Here goes a general summary of what this release is about -->
6-
7-
## Upgrading
8-
9-
<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->
10-
11-
## New Features
12-
13-
<!-- Here goes the main new features and examples or instructions on how to use them -->
14-
153
## Bug Fixes
164

17-
<!-- Here goes notable bug fixes that are worth a special mention or explanation -->
5+
- Fix a bug where SSL was enabled by default. It is now disabled by default as in previous versions.

src/frequenz/client/microgrid/_client.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import asyncio
77
import logging
88
from collections.abc import AsyncIterator, Awaitable, Callable, Iterable, Set
9+
from dataclasses import replace
910
from typing import Any, TypeVar, cast
1011

1112
import grpc.aio
@@ -44,13 +45,24 @@
4445
_logger = logging.getLogger(__name__)
4546

4647

48+
DEFAULT_CHANNEL_OPTIONS = replace(
49+
channel.ChannelOptions(), ssl=channel.SslOptions(enabled=False)
50+
)
51+
"""The default channel options for the microgrid API client.
52+
53+
These are the same defaults as the common default options but with SSL disabled, as the
54+
microgrid API does not use SSL by default.
55+
"""
56+
57+
4758
class ApiClient:
4859
"""A microgrid API client."""
4960

5061
def __init__(
5162
self,
5263
server_url: str,
5364
*,
65+
channel_options: channel.ChannelOptions = DEFAULT_CHANNEL_OPTIONS,
5466
retry_strategy: retry.Strategy | None = None,
5567
) -> None:
5668
"""Initialize the class instance.
@@ -62,14 +74,18 @@ def __init__(
6274
where the `port` should be an int between 0 and 65535 (defaulting to
6375
9090) and `ssl` should be a boolean (defaulting to `false`).
6476
For example: `grpc://localhost:1090?ssl=true`.
77+
channel_options: The default options use to create the channel when not
78+
specified in the URL.
6579
retry_strategy: The retry strategy to use to reconnect when the connection
6680
to the streaming method is lost. By default a linear backoff strategy
6781
is used.
6882
"""
6983
self._server_url = server_url
7084
"""The location of the microgrid API server as a URL."""
7185

72-
self.api = microgrid_pb2_grpc.MicrogridStub(channel.parse_grpc_uri(server_url))
86+
self.api = microgrid_pb2_grpc.MicrogridStub(
87+
channel.parse_grpc_uri(server_url, defaults=channel_options)
88+
)
7389
"""The gRPC stub for the microgrid API."""
7490

7591
self._broadcasters: dict[int, streaming.GrpcStreamBroadcaster[Any, Any]] = {}

0 commit comments

Comments
 (0)