Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rendezvous bypass mode #6681

Merged
merged 2 commits into from
May 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,7 @@ CHIP_ERROR DeviceCommissioner::PairTestDeviceWithoutSecurity(NodeId remoteDevice

SecurePairingUsingTestSecret * testSecurePairingSecret = nullptr;

// Check that the caller has provided an IP address (instead of a BLE peer address)
VerifyOrExit(peerAddress.GetTransportType() == Transport::Type::kUdp, err = CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrExit(remoteDeviceId != kUndefinedNodeId && remoteDeviceId != kAnyNodeId, err = CHIP_ERROR_INVALID_ARGUMENT);

Expand All @@ -848,7 +849,31 @@ CHIP_ERROR DeviceCommissioner::PairTestDeviceWithoutSecurity(NodeId remoteDevice

device->Serialize(serialized);

OnSessionEstablished();
err = mSessionMgr->NewPairing(Optional<Transport::PeerAddress>::Value(peerAddress), device->GetDeviceId(),
testSecurePairingSecret, SecureSession::SessionRole::kInitiator, mAdminId, nullptr);
if (err != CHIP_NO_ERROR)
{
ChipLogError(Controller, "Failed in setting up secure channel: err %s", ErrorStr(err));
OnSessionEstablishmentError(err);
}
SuccessOrExit(err);

mPairedDevices.Insert(device->GetDeviceId());
mPairedDevicesUpdated = true;

// Note - This assumes storage is synchronous, the device must be in storage before we can cleanup
// the rendezvous session and mark pairing success
PersistDevice(device);
// Also persist the device list at this time
// This makes sure that a newly added device is immediately available
PersistDeviceList();

if (mPairingDelegate != nullptr)
{
mPairingDelegate->OnStatusUpdate(DevicePairingDelegate::SecurePairingSuccess);
}

RendezvousCleanup(CHIP_NO_ERROR);

exit:
if (testSecurePairingSecret != nullptr)
Expand Down Expand Up @@ -967,7 +992,7 @@ void DeviceCommissioner::OnSessionEstablished()
SecureSession::SessionRole::kInitiator, mAdminId, nullptr);
if (err != CHIP_NO_ERROR)
{
ChipLogError(Ble, "Failed in setting up secure channel: err %s", ErrorStr(err));
ChipLogError(Controller, "Failed in setting up secure channel: err %s", ErrorStr(err));
OnSessionEstablishmentError(err);
return;
}
Expand All @@ -978,7 +1003,7 @@ void DeviceCommissioner::OnSessionEstablished()
err = SendOperationalCertificateSigningRequestCommand(device->GetDeviceId());
if (err != CHIP_NO_ERROR)
{
ChipLogError(Ble, "Failed in sending opcsr request command to the device: err %s", ErrorStr(err));
ChipLogError(Controller, "Failed in sending opcsr request command to the device: err %s", ErrorStr(err));
OnSessionEstablishmentError(err);
return;
}
Expand Down