Skip to content

Commit 3243893

Browse files
austinh0pull[bot]
authored andcommitted
Set key length in example issuer to value length (#14869)
1 parent 24aaf68 commit 3243893

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/controller/ExampleOperationalCredentialsIssuer.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ CHIP_ERROR ExampleOperationalCredentialsIssuer::Initialize(PersistentStorageDele
5656

5757
PERSISTENT_KEY_OP(mIndex, kOperationalCredentialsIssuerKeypairStorage, key,
5858
err = storage.SyncGetKeyValue(key, &serializedKey, keySize));
59+
serializedKey.SetLength(keySize);
5960

6061
if (err != CHIP_NO_ERROR)
6162
{
63+
ChipLogProgress(Controller, "Couldn't get %s from storage: %s", kOperationalCredentialsIssuerKeypairStorage, ErrorStr(err));
6264
// Storage doesn't have an existing keypair. Let's create one and add it to the storage.
6365
ReturnErrorOnFailure(mIssuer.Initialize());
6466
ReturnErrorOnFailure(mIssuer.Serialize(serializedKey));
@@ -78,9 +80,12 @@ CHIP_ERROR ExampleOperationalCredentialsIssuer::Initialize(PersistentStorageDele
7880

7981
PERSISTENT_KEY_OP(mIndex, kOperationalCredentialsIntermediateIssuerKeypairStorage, key,
8082
err = storage.SyncGetKeyValue(key, &serializedKey, keySize));
83+
serializedKey.SetLength(keySize);
8184

8285
if (err != CHIP_NO_ERROR)
8386
{
87+
ChipLogProgress(Controller, "Couldn't get %s from storage: %s", kOperationalCredentialsIntermediateIssuerKeypairStorage,
88+
ErrorStr(err));
8489
// Storage doesn't have an existing keypair. Let's create one and add it to the storage.
8590
ReturnErrorOnFailure(mIntermediateIssuer.Initialize());
8691
ReturnErrorOnFailure(mIntermediateIssuer.Serialize(serializedKey));

0 commit comments

Comments
 (0)