Skip to content

Commit

Permalink
Fix build warning on Android in CHIPCryptoPALOpenSSL.cpp (#21893)
Browse files Browse the repository at this point in the history
* Fix build warning on Android in CHIPCryptoPALOpenSSL.cpp

X509_VERIFY_PARAM_set_time takes in time_t as the unix epoch parameter.
On Android this is defined as a 'long', so need to cast the value to
suppress the warning.

src/crypto/CHIPCryptoPALOpenSSL.cpp:1672:43: error: implicit conversion changes signedness: 'uint32_t' (aka 'unsigned int') to 'time_t' (aka 'long') [-Werror,-Wsign-conversion]
        X509_VERIFY_PARAM_set_time(param, unixEpoch);

* Update src/crypto/CHIPCryptoPALOpenSSL.cpp

Co-authored-by: Evgeny Margolis <[email protected]>

Co-authored-by: Evgeny Margolis <[email protected]>
  • Loading branch information
dnicoara and emargolis authored Aug 15, 2022
1 parent 8d8b636 commit 38f3ebc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/crypto/CHIPCryptoPALOpenSSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1669,7 +1669,9 @@ CHIP_ERROR ValidateCertificateChain(const uint8_t * rootCertificate, size_t root
VerifyOrExit(asn1Time.ExportTo_UnixTime(unixEpoch),
(result = CertificateChainValidationResult::kLeafFormatInvalid, err = CHIP_ERROR_INTERNAL));

X509_VERIFY_PARAM_set_time(param, unixEpoch);
VerifyOrExit(CanCastTo<time_t>(unixEpoch),
(result = CertificateChainValidationResult::kLeafFormatInvalid, err = CHIP_ERROR_INTERNAL));
X509_VERIFY_PARAM_set_time(param, static_cast<time_t>(unixEpoch));
}

status = X509_verify_cert(verifyCtx);
Expand Down

0 comments on commit 38f3ebc

Please sign in to comment.