Fix cancellation handling during `GetPublicKey`.