Skip to content

Commit 2555714

Browse files
bzbarsky-applepull[bot]
authored andcommitted
Move the "ignore certificate validity dates" policy out of Server.h. (#26519)
This makes it easier to use for clients that don't have reliable wall-clock time.
1 parent bd2869f commit 2555714

File tree

4 files changed

+37
-39
lines changed

4 files changed

+37
-39
lines changed

examples/platform/nxp/se05x/linux/AppMain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ struct CommonCaseDeviceServerInitParams_Se05x : public CommonCaseDeviceServerIni
299299
static chip::PersistentStorageOperationalKeystoreHSM sPersistentStorageOperationalKeystore;
300300
static chip::Credentials::PersistentStorageOpCertStore sPersistentStorageOpCertStore;
301301
static chip::Credentials::GroupDataProviderImpl sGroupDataProvider;
302-
static IgnoreCertificateValidityPolicy sDefaultCertValidityPolicy;
302+
static Credentials::IgnoreCertificateValidityPeriodPolicy sDefaultCertValidityPolicy;
303303
static chip::Crypto::DefaultSessionKeystore sSessionKeystore;
304304

305305
#if CHIP_CONFIG_ENABLE_SESSION_RESUMPTION

src/app/server/Server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ KvsPersistentStorageDelegate CommonCaseDeviceServerInitParams::sKvsPersistenStor
535535
PersistentStorageOperationalKeystore CommonCaseDeviceServerInitParams::sPersistentStorageOperationalKeystore;
536536
Credentials::PersistentStorageOpCertStore CommonCaseDeviceServerInitParams::sPersistentStorageOpCertStore;
537537
Credentials::GroupDataProviderImpl CommonCaseDeviceServerInitParams::sGroupDataProvider;
538-
IgnoreCertificateValidityPolicy CommonCaseDeviceServerInitParams::sDefaultCertValidityPolicy;
538+
Credentials::IgnoreCertificateValidityPeriodPolicy CommonCaseDeviceServerInitParams::sDefaultCertValidityPolicy;
539539
#if CHIP_CONFIG_ENABLE_SESSION_RESUMPTION
540540
SimpleSessionResumptionStorage CommonCaseDeviceServerInitParams::sSessionResumptionStorage;
541541
#endif

src/app/server/Server.h

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -137,42 +137,6 @@ struct ServerInitParams
137137
Credentials::OperationalCertificateStore * opCertStore = nullptr;
138138
};
139139

140-
class IgnoreCertificateValidityPolicy : public Credentials::CertificateValidityPolicy
141-
{
142-
public:
143-
IgnoreCertificateValidityPolicy() {}
144-
145-
/**
146-
* @brief
147-
*
148-
* This certificate validity policy does not validate NotBefore or
149-
* NotAfter to accommodate platforms that may have wall clock time, but
150-
* where it is unreliable.
151-
*
152-
* Last Known Good Time is also not considered in this policy.
153-
*
154-
* @param cert CHIP Certificate for which we are evaluating validity
155-
* @param depth the depth of the certificate in the chain, where the leaf is at depth 0
156-
* @return CHIP_NO_ERROR if CHIPCert should accept the certificate; an appropriate CHIP_ERROR if it should be rejected
157-
*/
158-
CHIP_ERROR ApplyCertificateValidityPolicy(const Credentials::ChipCertificateData * cert, uint8_t depth,
159-
Credentials::CertificateValidityResult result) override
160-
{
161-
switch (result)
162-
{
163-
case Credentials::CertificateValidityResult::kValid:
164-
case Credentials::CertificateValidityResult::kNotYetValid:
165-
case Credentials::CertificateValidityResult::kExpired:
166-
case Credentials::CertificateValidityResult::kNotExpiredAtLastKnownGoodTime:
167-
case Credentials::CertificateValidityResult::kExpiredAtLastKnownGoodTime:
168-
case Credentials::CertificateValidityResult::kTimeUnknown:
169-
return CHIP_NO_ERROR;
170-
default:
171-
return CHIP_ERROR_INVALID_ARGUMENT;
172-
}
173-
}
174-
};
175-
176140
/**
177141
* Transitional version of ServerInitParams to assist SDK integrators in
178142
* transitioning to injecting product/platform-owned resources. This version
@@ -289,7 +253,7 @@ struct CommonCaseDeviceServerInitParams : public ServerInitParams
289253
static PersistentStorageOperationalKeystore sPersistentStorageOperationalKeystore;
290254
static Credentials::PersistentStorageOpCertStore sPersistentStorageOpCertStore;
291255
static Credentials::GroupDataProviderImpl sGroupDataProvider;
292-
static IgnoreCertificateValidityPolicy sDefaultCertValidityPolicy;
256+
static Credentials::IgnoreCertificateValidityPeriodPolicy sDefaultCertValidityPolicy;
293257
#if CHIP_CONFIG_ENABLE_SESSION_RESUMPTION
294258
static SimpleSessionResumptionStorage sSessionResumptionStorage;
295259
#endif

src/credentials/CertificateValidityPolicy.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,39 @@ class CertificateValidityPolicy
6060
static CHIP_ERROR ApplyDefaultPolicy(const ChipCertificateData * cert, uint8_t depth, CertificateValidityResult result);
6161
};
6262

63+
class IgnoreCertificateValidityPeriodPolicy : public CertificateValidityPolicy
64+
{
65+
public:
66+
IgnoreCertificateValidityPeriodPolicy() {}
67+
68+
/**
69+
* This certificate validity policy does not validate NotBefore or
70+
* NotAfter to accommodate platforms that may have wall clock time, but
71+
* where it is unreliable.
72+
*
73+
* Last Known Good Time is also not considered in this policy.
74+
*
75+
* @param cert CHIP Certificate for which we are evaluating validity
76+
* @param depth the depth of the certificate in the chain, where the leaf is at depth 0
77+
* @return CHIP_NO_ERROR if CHIPCert should accept the certificate; an appropriate CHIP_ERROR if it should be rejected
78+
*/
79+
CHIP_ERROR ApplyCertificateValidityPolicy(const Credentials::ChipCertificateData * cert, uint8_t depth,
80+
Credentials::CertificateValidityResult result) override
81+
{
82+
switch (result)
83+
{
84+
case Credentials::CertificateValidityResult::kValid:
85+
case Credentials::CertificateValidityResult::kNotYetValid:
86+
case Credentials::CertificateValidityResult::kExpired:
87+
case Credentials::CertificateValidityResult::kNotExpiredAtLastKnownGoodTime:
88+
case Credentials::CertificateValidityResult::kExpiredAtLastKnownGoodTime:
89+
case Credentials::CertificateValidityResult::kTimeUnknown:
90+
return CHIP_NO_ERROR;
91+
default:
92+
return CHIP_ERROR_INVALID_ARGUMENT;
93+
}
94+
}
95+
};
96+
6397
} // namespace Credentials
6498
} // namespace chip

0 commit comments

Comments
 (0)