diff options
author | Andrii Kalinich <AKalinich@luxoft.com> | 2018-06-12 19:16:49 +0300 |
---|---|---|
committer | AKalinich-Luxoft <AKalinich@luxoft.com> | 2018-06-13 14:17:04 +0300 |
commit | 572b06a2c5ab174a0be1a9b1526a41950564fa0a (patch) | |
tree | dd83643aec9d89980d9920c5fb295cf402031735 /src | |
parent | a194d35bcc39560ef47f39a5dd95cd75cfd193ba (diff) | |
download | sdl_core-572b06a2c5ab174a0be1a9b1526a41950564fa0a.tar.gz |
Fixed time zones issue while checking certificate exp date
Diffstat (limited to 'src')
-rw-r--r-- | src/components/security_manager/src/ssl_context_impl.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/components/security_manager/src/ssl_context_impl.cc b/src/components/security_manager/src/ssl_context_impl.cc index 866e825e0b..75e2c8a4f8 100644 --- a/src/components/security_manager/src/ssl_context_impl.cc +++ b/src/components/security_manager/src/ssl_context_impl.cc @@ -36,6 +36,7 @@ #include <map> #include <algorithm> #include <vector> +#include <time.h> #include <openssl/bio.h> #include <openssl/ssl.h> @@ -113,6 +114,12 @@ size_t des_cbc3_sha_max_block_size(size_t mtu) { return 0; return ((mtu - 29) & 0xfffffff8) - 5; } +time_t get_time_zone_offset(time_t in_time) { + tm gmt_cert_tm = *gmtime(&in_time); + tm local_cert_tm = *localtime(&in_time); + + return mktime(&local_cert_tm) - mktime(&gmt_cert_tm); +} } // namespace std::map<std::string, CryptoManagerImpl::SSLContextImpl::BlockSizeGetter> @@ -328,7 +335,10 @@ time_t CryptoManagerImpl::SSLContextImpl::convert_asn1_time_to_time_t( cert_time.tm_sec = sec; } - return mktime(&cert_time); + const time_t local_cert_time = mktime(&cert_time); + const time_t time_offset = get_time_zone_offset(local_cert_time); + + return local_cert_time + time_offset; } bool CryptoManagerImpl::SSLContextImpl::ReadHandshakeData( |