Skip to content

Commit

Permalink
Fix Darwin CI
Browse files Browse the repository at this point in the history
  • Loading branch information
tcarmelveilleux committed Jun 13, 2022
1 parent d956b35 commit 4a69a1d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/controller/CHIPDeviceController.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,15 @@ class DLL_EXPORT DeviceController : public AbstractDnssdDiscoveryController

FabricInfo * GetFabricInfo() { return mFabricInfo; }

const FabricTable * GetFabricTable() const
{
if (mSystemState == nullptr)
{
return nullptr;
}
return mSystemState->Fabrics();
}

void ReleaseOperationalDevice(NodeId remoteDeviceId);

OperationalCredentialsDelegate * GetOperationalCredentialsDelegate() { return mOperationalCredentialsDelegate; }
Expand Down
10 changes: 8 additions & 2 deletions src/darwin/Framework/CHIP/CHIPDeviceController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -748,9 +748,15 @@ - (CHIP_ERROR)isRunningOnFabric:(chip::FabricInfo *)fabric isRunning:(BOOL *)isR
return CHIP_NO_ERROR;
}

chip::Credentials::FabricTable * fabricTable = _cppCommissioner->GetFabricTable();
if (!fabricTable) {
// Surprising as well!
return CHIP_ERROR_INCORRECT_STATE;
}

chip::Credentials::P256PublicKey ourRootPublicKey, otherRootPublicKey;
ReturnErrorOnFailure(ourFabric->FetchRootPubkey(ourRootPublicKey));
ReturnErrorOnFailure(fabric->FetchRootPubkey(otherRootPublicKey));
ReturnErrorOnFailure(fabricTable->FetchRootPubkey(ourFabric->GetFabricIndex(), ourRootPublicKey));
ReturnErrorOnFailure(fabricTable->FetchRootPubkey(fabric->GetFabricIndex(), otherRootPublicKey));

*isRunning = (ourRootPublicKey.Matches(otherRootPublicKey));
return CHIP_NO_ERROR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ - (instancetype)initForExistingFabric:(FabricTable *)fabricTable
if (self.operationalKeypair == nil) {
uint8_t nocBuf[Credentials::kMaxCHIPCertLength];
MutableByteSpan noc(nocBuf);
CHIP_ERROR err = fabric->FetchNOCCert(noc);
CHIP_ERROR err = fabricTable->FetchNOCCert(fabric->GetFabricIndex(), noc);
if (err != CHIP_NO_ERROR) {
CHIP_LOG_ERROR("Failed to get existing NOC: %s", ErrorStr(err));
return nil;
Expand All @@ -240,7 +240,7 @@ - (instancetype)initForExistingFabric:(FabricTable *)fabricTable
{
uint8_t icaBuf[Credentials::kMaxCHIPCertLength];
MutableByteSpan icaCert(icaBuf);
CHIP_ERROR err = fabric->FetchICACert(icaCert);
CHIP_ERROR err = fabricTable->FetchICACert(fabric->GetFabricIndex(), icaCert);
if (err != CHIP_NO_ERROR) {
CHIP_LOG_ERROR("Failed to get existing intermediate certificate: %s", ErrorStr(err));
return nil;
Expand Down Expand Up @@ -282,7 +282,7 @@ - (instancetype)initForExistingFabric:(FabricTable *)fabricTable
{
uint8_t rootBuf[Credentials::kMaxCHIPCertLength];
MutableByteSpan rootCert(rootBuf);
CHIP_ERROR err = fabric->FetchRootCert(rootCert);
CHIP_ERROR err = fabricTable->FetchRootCert(fabric->GetFabricIndex(), rootCert);
if (err != CHIP_NO_ERROR) {
CHIP_LOG_ERROR("Failed to get existing root certificate: %s", ErrorStr(err));
return nil;
Expand Down

0 comments on commit 4a69a1d

Please sign in to comment.