After the server rejected a key: look for its key again, unless the user set it. Returns the new key, or None when there is no other key to try.
(context)
| 377 | |
| 378 | |
| 379 | def refetch_server_key(context): # type: (RestApiContext) -> Optional[SelfManagedServerKey] |
| 380 | """After the server rejected a key: look for its key again, unless the user set it. |
| 381 | Returns the new key, or None when there is no other key to try.""" |
| 382 | host = server_host(context.server_base) |
| 383 | old_key = _resolved_server_keys.get(host) |
| 384 | if old_key is not None and not old_key.fetched: |
| 385 | return None |
| 386 | _resolved_server_keys.pop(host, None) |
| 387 | _server_key_errors.pop(host, None) |
| 388 | new_key = get_self_managed_server_key(context) |
| 389 | if new_key is None: |
| 390 | return None |
| 391 | if old_key is not None and (new_key.key_id, new_key.public_key) == (old_key.key_id, old_key.public_key): |
| 392 | return None |
| 393 | return new_key |
| 394 | |
| 395 | |
| 396 | def get_server_public_key(context): # type: (RestApiContext) -> Union[rsa.RSAPublicKey, ec.EllipticCurvePublicKey] |
no test coverage detected