Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Clean up remaining references to automatic provisioning.
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
  • Loading branch information
pattivacek committed May 27, 2019
1 parent 083c325 commit b4af839
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docs/provision-with-device-credentials.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
+
----
Expand Down
2 changes: 1 addition & 1 deletion src/aktualizr_primary/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bpo::variables_map parse_options(int argc, char *argv[]) {
("config,c", bpo::value<std::vector<boost::filesystem::path> >()->composing(), "configuration file or directory")
("loglevel", bpo::value<int>(), "set log level 0-5 (trace, debug, info, warning, error, fatal)")
("run-mode", bpo::value<std::string>(), "run mode of aktualizr: full, once, campaign_check, campaign_accept, check, download, or install")
("tls-server", bpo::value<std::string>(), "url, used for auto provisioning")
("tls-server", bpo::value<std::string>(), "url of device gateway")
("repo-server", bpo::value<std::string>(), "url of the uptane repo repository")
("director-server", bpo::value<std::string>(), "url of the uptane director repository")
("ostree-server", bpo::value<std::string>(), "url of the ostree repository")
Expand Down
2 changes: 1 addition & 1 deletion src/cert_provider/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
29 changes: 15 additions & 14 deletions src/libaktualizr/primary/initializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -188,15 +189,15 @@ 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;
return InitRetCode::kServerFailure;
}
// 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;
}

Expand All @@ -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;
}

Expand All @@ -222,32 +223,32 @@ 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;
}

ret_code = initEcuRegister();
// 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;
}

Expand All @@ -260,5 +261,5 @@ Initializer::Initializer(
success_ = true;
return;
}
LOG_ERROR << "Initialization failed after " << MaxInitializationAttempts << " attempts";
LOG_ERROR << "Initialization failed after " << MaxInitializationAttempts << " attempts.";
}

0 comments on commit b4af839

Please sign in to comment.