Skip to content

Commit c333bb4

Browse files
committed
Rename pinned_ca_cert_hash to ssl_fingerprint
1 parent 3ba8eff commit c333bb4

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fingerprint = await async_fetch_remote_fingerprint("https://kvm.local/api/")
118118
# Then connect with the pinned fingerprint
119119
async with NanoKVMClient(
120120
"https://kvm.local/api/",
121-
pinned_ca_cert_hash=fingerprint,
121+
ssl_fingerprint=fingerprint,
122122
) as client:
123123
await client.authenticate("username", "password")
124124
```

nanokvm/client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def __init__(
126126
session: ClientSession | None = None,
127127
verify_ssl: bool = True,
128128
ssl_ca_cert: str | None = None,
129-
pinned_ca_cert_hash: str | None = None,
129+
ssl_fingerprint: str | None = None,
130130
use_password_obfuscation: bool | None = None,
131131
) -> None:
132132
"""
@@ -141,7 +141,7 @@ def __init__(
141141
Set to False to disable verification for self-signed certificates.
142142
ssl_ca_cert: Path to custom CA certificate bundle file for SSL verification.
143143
Useful for self-signed certificates or private CAs.
144-
pinned_ca_cert_hash: SHA-256 fingerprint of the server's TLS certificate
144+
ssl_fingerprint: SHA-256 fingerprint of the server's TLS certificate
145145
as a hex string. When set, the client will verify the server's
146146
certificate fingerprint instead of performing CA-based verification.
147147
Use `async_fetch_remote_fingerprint()` to retrieve this value.
@@ -158,7 +158,7 @@ def __init__(
158158
self._ws: aiohttp.ClientWebSocketResponse | None = None
159159
self._verify_ssl = verify_ssl
160160
self._ssl_ca_cert = ssl_ca_cert
161-
self._pinned_ca_cert_hash = pinned_ca_cert_hash
161+
self._ssl_fingerprint = ssl_fingerprint
162162
self._use_password_obfuscation = use_password_obfuscation
163163
self._ssl_config: ssl.SSLContext | Fingerprint | bool | None = None
164164

@@ -167,7 +167,7 @@ def _create_ssl_context(self) -> ssl.SSLContext | Fingerprint | bool:
167167
Create and configure SSL context based on initialization parameters.
168168
169169
Returns:
170-
Fingerprint: Certificate fingerprint pinning (when pinned_ca_cert_hash set)
170+
Fingerprint: Certificate fingerprint pinning (when ssl_fingerprint set)
171171
ssl.SSLContext: Configured SSL context for custom certificates
172172
True: Use default SSL verification (aiohttp default)
173173
False: Disable SSL verification
@@ -177,9 +177,9 @@ def _create_ssl_context(self) -> ssl.SSLContext | Fingerprint | bool:
177177
ssl.SSLError: If the CA certificate is invalid.
178178
"""
179179

180-
if self._pinned_ca_cert_hash:
180+
if self._ssl_fingerprint:
181181
_LOGGER.debug("Using certificate fingerprint pinning")
182-
return Fingerprint(bytes.fromhex(self._pinned_ca_cert_hash))
182+
return Fingerprint(bytes.fromhex(self._ssl_fingerprint))
183183

184184
if not self._verify_ssl:
185185
_LOGGER.warning(

nanokvm/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async def async_fetch_remote_fingerprint(url: str) -> str:
5353
then returns its SHA-256 hash as an uppercase hex string.
5454
5555
This is useful for establishing an initial trust-on-first-use pin with
56-
`NanoKVMClient(url, pinned_ca_cert_hash=...)`.
56+
`NanoKVMClient(url, ssl_fingerprint=...)`.
5757
"""
5858
parsed_url = urllib.parse.urlparse(url)
5959
hostname = parsed_url.hostname

tests/test_certificate_pinning.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ async def test_certificate_pinning(nanokvm_https_server: str) -> None:
165165
# Step 3: pinned fingerprint allows the connection to succeed
166166
async with NanoKVMClient(
167167
url,
168-
pinned_ca_cert_hash=fingerprint,
168+
ssl_fingerprint=fingerprint,
169169
use_password_obfuscation=False,
170170
) as client:
171171
await client.authenticate("admin", "test")
@@ -178,7 +178,7 @@ async def test_certificate_pinning_wrong_hash(nanokvm_https_server: str) -> None
178178

179179
async with NanoKVMClient(
180180
url,
181-
pinned_ca_cert_hash="AB" * 32,
181+
ssl_fingerprint="AB" * 32,
182182
use_password_obfuscation=False,
183183
) as client:
184184
with pytest.raises(aiohttp.ServerFingerprintMismatch):

0 commit comments

Comments
 (0)