Skip to content

Commit

Permalink
Add explicit warning for PID/VID mismatch.
Browse files Browse the repository at this point in the history
  • Loading branch information
cecille committed Feb 7, 2022
1 parent cdf4eaf commit 3c5fbfd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/controller/AutoCommissioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,16 @@ CHIP_ERROR AutoCommissioner::CommissioningStepFinished(CHIP_ERROR err, Commissio
if (err != CHIP_NO_ERROR)
{
ChipLogError(Controller, "Failed to perform commissioning step %d", static_cast<int>(report.stageCompleted));
if (report.stageCompleted == CommissioningStage::kAttestationVerification &&
(report.Get<AdditionalErrorInfo>().attestationResult ==
Credentials::AttestationVerificationResult::kDacProductIdMismatch ||
report.Get<AdditionalErrorInfo>().attestationResult ==
Credentials::AttestationVerificationResult::kDacVendorIdMismatch))
{
ChipLogError(Controller,
"Failed device attestation. Device vendor and/or product ID do not match the IDs given in the device "
"attestation certificate");
}
}
else
{
Expand Down
6 changes: 4 additions & 2 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,12 +1126,14 @@ void DeviceCommissioner::OnDeviceAttestationInformationVerification(void * conte

if (result != AttestationVerificationResult::kSuccess)
{
CommissioningDelegate::CommissioningReport report;
report.Set<AdditionalErrorInfo>(result);
if (result == AttestationVerificationResult::kNotImplemented)
{
ChipLogError(Controller,
"Failed in verifying 'Attestation Information' command received from the device due to default "
"DeviceAttestationVerifier Class not being overridden by a real implementation.");
commissioner->CommissioningStageComplete(CHIP_ERROR_NOT_IMPLEMENTED);
commissioner->CommissioningStageComplete(CHIP_ERROR_NOT_IMPLEMENTED, report);
return;
}
else
Expand All @@ -1142,7 +1144,7 @@ void DeviceCommissioner::OnDeviceAttestationInformationVerification(void * conte
static_cast<uint16_t>(result));
// Go look at AttestationVerificationResult enum in src/credentials/DeviceAttestationVerifier.h to understand the
// errors.
commissioner->CommissioningStageComplete(CHIP_ERROR_INTERNAL);
commissioner->CommissioningStageComplete(CHIP_ERROR_INTERNAL, report);
return;
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/controller/CommissioningDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#pragma once
#include <app/OperationalDeviceProxy.h>
#include <controller/CommissioneeDeviceProxy.h>
#include <credentials/DeviceAttestationVerifier.h>
#include <lib/support/Variant.h>

namespace chip {
Expand Down Expand Up @@ -264,12 +265,18 @@ struct NetworkClusters
EndpointId eth = kInvalidEndpointId;
};

struct AdditionalErrorInfo
{
AdditionalErrorInfo(Credentials::AttestationVerificationResult result) : attestationResult(result) {}
Credentials::AttestationVerificationResult attestationResult;
};

class CommissioningDelegate
{
public:
virtual ~CommissioningDelegate(){};
struct CommissioningReport : Variant<RequestedCertificate, AttestationResponse, NocChain, OperationalNodeFoundData, BasicVendor,
BasicProduct, BasicSoftware, NetworkClusters>
BasicProduct, BasicSoftware, NetworkClusters, AdditionalErrorInfo>
{
CommissioningReport() : stageCompleted(CommissioningStage::kError) {}
CommissioningStage stageCompleted;
Expand Down

0 comments on commit 3c5fbfd

Please sign in to comment.