Skip to content

Commit a7a7f5a

Browse files
committed
Verify OCSP certificate by producedat time
IB-3995
1 parent 9897b10 commit a7a7f5a

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/crypto/OCSP.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "Conf.h"
2525
#include "crypto/OpenSSLHelpers.h"
2626
#include "crypto/X509CertStore.h"
27+
#include "util/DateTime.h"
2728

2829
#include <algorithm>
2930

@@ -442,6 +443,10 @@ void OCSP::verifyResponse(const X509Cert &cert) const
442443
}
443444
});
444445

446+
tm t = util::date::ASN1TimeToTM(producedAt());
447+
X509_VERIFY_PARAM_set_time(store->param, util::date::mkgmtime(t));
448+
X509_STORE_set_flags(store.get(), X509_V_FLAG_USE_CHECK_TIME);
449+
445450
//X509_STORE_set_trust(store.get(), X509_TRUST_TRUSTED);
446451
//X509_STORE_set_purpose(store.get(), NID_OCSP_sign);
447452

src/util/DateTime.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ time_t digidoc::util::date::string2time_t(const string &time)
127127
,0
128128
#endif
129129
};
130+
return mkgmtime(t);
131+
}
130132

133+
time_t digidoc::util::date::mkgmtime(struct tm &t)
134+
{
131135
#ifdef _WIN32
132136
return _mkgmtime(&t);
133137
#else

src/util/DateTime.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ namespace digidoc
3030
{
3131
namespace date
3232
{
33+
time_t mkgmtime(struct tm &t);
3334
tm ASN1TimeToTM(const std::string &date);
3435
std::string xsd2string(const xml_schema::DateTime &time);
3536
time_t string2time_t(const std::string &time);

0 commit comments

Comments
 (0)