File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ def _create_ssl_context(self) -> ssl.SSLContext | Fingerprint | bool:
179179
180180 if self ._ssl_fingerprint :
181181 _LOGGER .debug ("Using certificate fingerprint pinning" )
182- return Fingerprint (bytes .fromhex (self ._ssl_fingerprint ))
182+ return Fingerprint (bytes .fromhex (self ._ssl_fingerprint . replace ( ":" , "" ) ))
183183
184184 if not self ._verify_ssl :
185185 _LOGGER .warning (
Original file line number Diff line number Diff line change @@ -173,6 +173,25 @@ async def test_certificate_pinning(nanokvm_https_server: str) -> None:
173173 assert client .token == "fake-token-123"
174174
175175
176+ async def test_certificate_pinning_colon_separated (nanokvm_https_server : str ) -> None :
177+ """Test that colon-separated fingerprints (e.g. from openssl) are accepted."""
178+ url = nanokvm_https_server
179+ fingerprint = await async_fetch_remote_fingerprint (url )
180+
181+ # Convert "AABB..." to "AA:BB:..."
182+ colon_fingerprint = ":" .join (
183+ fingerprint [i : i + 2 ] for i in range (0 , len (fingerprint ), 2 )
184+ )
185+
186+ async with NanoKVMClient (
187+ url ,
188+ ssl_fingerprint = colon_fingerprint ,
189+ use_password_obfuscation = False ,
190+ ) as client :
191+ await client .authenticate ("admin" , "test" )
192+ assert client .token == "fake-token-123"
193+
194+
176195async def test_certificate_pinning_wrong_hash (nanokvm_https_server : str ) -> None :
177196 """Test that a wrong pinned hash is rejected."""
178197 url = nanokvm_https_server
You can’t perform that action at this time.
0 commit comments