Skip to content

Commit b867b06

Browse files
refactor: allow cert chain for server cert
1 parent bd79cde commit b867b06

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

google/cloud/sql/connector/connection_info.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from dataclasses import dataclass
1818
import logging
1919
import ssl
20-
from typing import Any, Dict, Optional, TYPE_CHECKING
20+
from typing import Any, Dict, List, Optional, TYPE_CHECKING
2121

2222
from aiofiles.tempfile import TemporaryDirectory
2323

@@ -39,7 +39,7 @@ class ConnectionInfo:
3939
server-side Proxy running on a Cloud SQL instance."""
4040

4141
client_cert: str
42-
server_ca_cert: str
42+
server_ca_cert: List[str]
4343
private_key: bytes
4444
ip_addrs: Dict[str, Any]
4545
database_version: str

google/cloud/sql/connector/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
"""
1616

17-
from typing import Tuple
17+
from typing import List, Tuple
1818

1919
import aiofiles
2020
from cryptography.hazmat.backends import default_backend
@@ -60,7 +60,7 @@ async def generate_keys() -> Tuple[bytes, str]:
6060

6161

6262
async def write_to_file(
63-
dir_path: str, serverCaCert: str, ephemeralCert: str, priv_key: bytes
63+
dir_path: str, serverCaCert: List[str], ephemeralCert: str, priv_key: bytes
6464
) -> Tuple[str, str, str]:
6565
"""
6666
Helper function to write the serverCaCert, ephemeral certificate and
@@ -71,7 +71,7 @@ async def write_to_file(
7171
key_filename = f"{dir_path}/priv.pem"
7272

7373
async with aiofiles.open(ca_filename, "w+") as ca_out:
74-
await ca_out.write(serverCaCert)
74+
await ca_out.write("".join(serverCaCert))
7575
async with aiofiles.open(cert_filename, "w+") as ephemeral_out:
7676
await ephemeral_out.write(ephemeralCert)
7777
async with aiofiles.open(key_filename, "wb") as priv_out:

0 commit comments

Comments
 (0)