Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Commit 011248d

Browse files
committed
Use dummy san for certificates
1 parent f88c708 commit 011248d

2 files changed

Lines changed: 4 additions & 31 deletions

File tree

packages/jumpstarter/jumpstarter/client/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from .grpc import SmartExporterStub
1111
from jumpstarter.client import DriverClient
1212
from jumpstarter.common.importlib import import_class
13+
from jumpstarter.exporter.tls import SAN
1314

1415

1516
@asynccontextmanager
@@ -54,6 +55,7 @@ async def client_from_channel(
5455
private_key=endpoint.client_private_key.encode(),
5556
certificate_chain=endpoint.client_certificate.encode(),
5657
),
58+
options=(("grpc.ssl_target_name_override", SAN),),
5759
)
5860
)
5961

packages/jumpstarter/jumpstarter/exporter/tls.py

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from datetime import datetime, timedelta
2-
from ipaddress import IPv4Address, IPv6Address, ip_address
32

43
import grpc
54
from cryptography import x509
@@ -8,38 +7,10 @@
87
from cryptography.hazmat.primitives.asymmetric import rsa
98
from jumpstarter_protocol import jumpstarter_pb2
109

11-
12-
def parse_endpoint(endpoint):
13-
host, sep, port = endpoint.rpartition(":")
14-
15-
if sep == "":
16-
raise ValueError("port not specified in endpoint {}".format(endpoint))
17-
18-
host = host.strip("[]") # strip brackets from ipv6 addresses
19-
20-
try:
21-
port = int(port)
22-
if port < 0 or port > 65535:
23-
raise ValueError("port number {} out of range".format(port))
24-
except ValueError as e:
25-
raise ValueError("invalid port {} in endpoint {}".format(port, endpoint)) from e
26-
27-
try:
28-
return ip_address(host), port
29-
except ValueError:
30-
return host, port
10+
SAN = "localhost"
3111

3212

3313
def with_alternative_endpoints(server, endpoints: list[str]):
34-
sans = []
35-
for endpoint in endpoints:
36-
host, port = parse_endpoint(endpoint)
37-
match host:
38-
case str():
39-
sans.append(x509.DNSName(host))
40-
case IPv4Address() | IPv6Address():
41-
sans.append(x509.IPAddress(host))
42-
4314
key = rsa.generate_private_key(public_exponent=65537, key_size=2048, backend=default_backend())
4415
client_key = rsa.generate_private_key(public_exponent=65537, key_size=2048, backend=default_backend())
4516

@@ -51,7 +22,7 @@ def with_alternative_endpoints(server, endpoints: list[str]):
5122
.serial_number(x509.random_serial_number())
5223
.not_valid_before(datetime.now())
5324
.not_valid_after(datetime.now() + timedelta(days=365))
54-
.add_extension(x509.SubjectAlternativeName(sans), critical=False)
25+
.add_extension(x509.SubjectAlternativeName([x509.DNSName(SAN)]), critical=False)
5526
.sign(private_key=key, algorithm=hashes.SHA256(), backend=default_backend())
5627
)
5728
client_crt = (

0 commit comments

Comments
 (0)