From b4af839e47ce716354c96f7fb97fb0b37641c488 Mon Sep 17 00:00:00 2001 From: Patrick Vacek Date: Mon, 27 May 2019 17:36:09 +0200 Subject: [PATCH] Clean up remaining references to automatic provisioning. Signed-off-by: Patrick Vacek --- docs/provision-with-device-credentials.adoc | 2 +- src/aktualizr_primary/main.cc | 2 +- src/cert_provider/main.cc | 2 +- src/libaktualizr/primary/initializer.cc | 29 +++++++++++---------- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/docs/provision-with-device-credentials.adoc b/docs/provision-with-device-credentials.adoc index d3690ef35f..31c0fa91b7 100644 --- a/docs/provision-with-device-credentials.adoc +++ b/docs/provision-with-device-credentials.adoc @@ -29,7 +29,7 @@ SOTA_DEPLOY_CREDENTIALS = "0" 1. Build a standard image using the bitbake command. 1. Boot the image. + -The device should not automatically provision its credentials. To verify this, log in to the OTA Connect server and make sure that the device does not appear in the list of devices. +The device should not be able to provision at this time. To verify this, log in to the OTA Connect server and make sure that the device does not appear in the list of devices. 1. Load the device credentials on to the device with `aktualizr-cert-provider` command: + ---- diff --git a/src/aktualizr_primary/main.cc b/src/aktualizr_primary/main.cc index c2b5303987..b147a25bd3 100644 --- a/src/aktualizr_primary/main.cc +++ b/src/aktualizr_primary/main.cc @@ -36,7 +36,7 @@ bpo::variables_map parse_options(int argc, char *argv[]) { ("config,c", bpo::value >()->composing(), "configuration file or directory") ("loglevel", bpo::value(), "set log level 0-5 (trace, debug, info, warning, error, fatal)") ("run-mode", bpo::value(), "run mode of aktualizr: full, once, campaign_check, campaign_accept, check, download, or install") - ("tls-server", bpo::value(), "url, used for auto provisioning") + ("tls-server", bpo::value(), "url of device gateway") ("repo-server", bpo::value(), "url of the uptane repo repository") ("director-server", bpo::value(), "url of the uptane director repository") ("ostree-server", bpo::value(), "url of the ostree repository") diff --git a/src/cert_provider/main.cc b/src/cert_provider/main.cc index e22986ddb2..5ba80116fd 100644 --- a/src/cert_provider/main.cc +++ b/src/cert_provider/main.cc @@ -457,7 +457,7 @@ int main(int argc, char* argv[]) { std::string cert; std::string ca; - if (fleet_ca_path.empty()) { // no fleet ca => autoprovision + if (fleet_ca_path.empty()) { // no fleet CA => provision with shared credentials std::string device_id = Utils::genPrettyName(); std::cout << "Random device ID is " << device_id << "\n"; diff --git a/src/libaktualizr/primary/initializer.cc b/src/libaktualizr/primary/initializer.cc index b0cdde1ae9..0a16ffddfd 100644 --- a/src/libaktualizr/primary/initializer.cc +++ b/src/libaktualizr/primary/initializer.cc @@ -92,7 +92,8 @@ InitRetCode Initializer::initTlsCreds() { return InitRetCode::kStorageFailure; } - // Autoprovision is needed and possible => autoprovision + // Shared credential provision is required and possible => (automatically) + // provision with shared credentials. // set bootstrap credentials Bootstrap boot(config_.provision_path, config_.p12_password); @@ -102,7 +103,7 @@ InitRetCode Initializer::initTlsCreds() { Json::Value data; std::string device_id; if (!storage_->loadDeviceId(&device_id)) { - LOG_ERROR << "device_id unknown during autoprovisioning process"; + LOG_ERROR << "Unknown device_id during shared credential provisioning."; return InitRetCode::kStorageFailure; } data["deviceId"] = device_id; @@ -114,7 +115,7 @@ InitRetCode Initializer::initTlsCreds() { LOG_ERROR << "Device id" << device_id << "is occupied"; return InitRetCode::kOccupied; } - LOG_ERROR << "Autoprovisioning failed, response: " << response.body; + LOG_ERROR << "Shared credential provisioning failed, response: " << response.body; return InitRetCode::kServerFailure; } @@ -188,7 +189,7 @@ InitRetCode Initializer::initEcuRegister() { Json::Value resp_code = response.getJson()["code"]; if (resp_code.isString() && (resp_code.asString() == "ecu_already_registered" || resp_code.asString() == "device_already_registered")) { - LOG_ERROR << "Some ECU is already registered"; + LOG_ERROR << "One or more ECUs are unexpectedly already registered."; return InitRetCode::kOccupied; } LOG_ERROR << "Error registering device on Uptane, response: " << response.body; @@ -196,7 +197,7 @@ InitRetCode Initializer::initEcuRegister() { } // do not call storage_->storeEcuRegistered(), it will be called from the top-level Init function after the // acknowledgement - LOG_INFO << "ECUs have been successfully registered to the server"; + LOG_INFO << "ECUs have been successfully registered to the server."; return InitRetCode::kOk; } @@ -213,7 +214,7 @@ Initializer::Initializer( success_ = false; for (int i = 0; i < MaxInitializationAttempts; i++) { if (!initDeviceId()) { - LOG_ERROR << "Device ID generation failed, abort initialization"; + LOG_ERROR << "Device ID generation failed. Aborting initialization."; return; } @@ -222,22 +223,22 @@ Initializer::Initializer( // generate a new one if (ret_code == InitRetCode::kOccupied) { resetDeviceId(); - LOG_INFO << "Device name is already registered, restart"; + LOG_INFO << "Device name is already registered. Restarting."; continue; } else if (ret_code == InitRetCode::kStorageFailure) { - LOG_ERROR << "Error reading existing provisioning data from storage"; + LOG_ERROR << "Error reading existing provisioning data from storage."; return; } else if (ret_code != InitRetCode::kOk) { - LOG_ERROR << "Autoprovisioning failed, abort initialization"; + LOG_ERROR << "Shared credential provisioning failed. Aborting initialization."; return; } if (!initPrimaryEcuKeys()) { - LOG_ERROR << "ECU key generation failed, abort initialization"; + LOG_ERROR << "ECU key generation failed. Aborting initialization."; return; } if (!initEcuSerials()) { - LOG_ERROR << "ECU serial generation failed, abort initialization"; + LOG_ERROR << "ECU serial generation failed. Aborting initialization."; return; } @@ -245,9 +246,9 @@ Initializer::Initializer( // if ECUs with same ID have been registered to the server, we don't have a // clear remediation path right now, just ignore the error if (ret_code == InitRetCode::kOccupied) { - LOG_INFO << "ECU serial is already registered"; + LOG_INFO << "ECU serial is already registered."; } else if (ret_code != InitRetCode::kOk) { - LOG_ERROR << "ECU registration failed, abort initialization"; + LOG_ERROR << "ECU registration failed. Aborting initialization."; return; } @@ -260,5 +261,5 @@ Initializer::Initializer( success_ = true; return; } - LOG_ERROR << "Initialization failed after " << MaxInitializationAttempts << " attempts"; + LOG_ERROR << "Initialization failed after " << MaxInitializationAttempts << " attempts."; }