(context, host)
| 315 | |
| 316 | |
| 317 | def _fetch_server_key(context, host): # type: (RestApiContext, str) -> SelfManagedServerKey |
| 318 | scheme = urlparse(context.server_base).scheme or 'https' |
| 319 | urls = (context.server_base + SERVER_KEY_ENDPOINT, f'{scheme}://{host}{LEGACY_SERVER_KEY_PATH}') |
| 320 | errors = [] |
| 321 | for url in urls: |
| 322 | try: |
| 323 | key = _fetch_server_key_from(context, url) |
| 324 | except Exception as e: |
| 325 | errors.append(f'{url}: {e}') |
| 326 | continue |
| 327 | logging.info('Server key of %s: key ID %d, %s (fetched from %s)', |
| 328 | host, key.key_id, server_key_fingerprint(key.public_key), url) |
| 329 | return key |
| 330 | raise ValueError('; '.join(errors)) |
| 331 | |
| 332 | |
| 333 | def _environment_server_key(): # type: () -> Optional[SelfManagedServerKey] |
no test coverage detected