diff --git a/sharing/certificates/nearby_share_certificate_manager_impl.cc b/sharing/certificates/nearby_share_certificate_manager_impl.cc index 78c0d47759..0f2508b01a 100644 --- a/sharing/certificates/nearby_share_certificate_manager_impl.cc +++ b/sharing/certificates/nearby_share_certificate_manager_impl.cc @@ -723,6 +723,15 @@ void NearbyShareCertificateManagerImpl::PrivateCertificateRefresh( absl::Time now = context_->GetClock()->Now(); certificate_storage_->RemoveExpiredPrivateCertificates(now); + std::optional account = + account_manager_.GetCurrentAccount(); + if (!account.has_value()) { + LOG(INFO) << "Not logged in on refreshing private certificates, ignoring"; + private_certificate_expiration_scheduler_->HandleResult( + /*success=*/true); + return; + } + std::vector certs = *certificate_storage_->GetPrivateCertificates(); if (certs.size() == NumExpectedPrivateCertificates()) { @@ -753,8 +762,6 @@ void NearbyShareCertificateManagerImpl::PrivateCertificateRefresh( std::max(latest_not_after[cert.visibility()], cert.not_after()); } - std::optional account = - account_manager_.GetCurrentAccount(); std::optional email = account.has_value() ? account->email