mirror of
https://github.com/pocoproject/poco.git
synced 2025-11-24 06:04:15 +01:00
fixed GH #2743: X509Certificate validFrom expiresOn Date parsing
This commit is contained in:
@@ -305,8 +305,19 @@ Poco::DateTime X509Certificate::validFrom() const
|
||||
const ASN1_TIME* certTime = X509_get0_notBefore(_pCert);
|
||||
std::string dateTime(reinterpret_cast<char*>(certTime->data));
|
||||
int tzd;
|
||||
if (certTime->type == V_ASN1_UTCTIME)
|
||||
{
|
||||
return DateTimeParser::parse("%y%m%d%H%M%S", dateTime, tzd);
|
||||
}
|
||||
else if (certTime->type == V_ASN1_GENERALIZEDTIME)
|
||||
{
|
||||
return DateTimeParser::parse("%Y%m%d%H%M%S", dateTime, tzd);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw NotImplementedException("Unsupported date/time format in notBefore");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Poco::DateTime X509Certificate::expiresOn() const
|
||||
@@ -314,8 +325,19 @@ Poco::DateTime X509Certificate::expiresOn() const
|
||||
const ASN1_TIME* certTime = X509_get0_notAfter(_pCert);
|
||||
std::string dateTime(reinterpret_cast<char*>(certTime->data));
|
||||
int tzd;
|
||||
if (certTime->type == V_ASN1_UTCTIME)
|
||||
{
|
||||
return DateTimeParser::parse("%y%m%d%H%M%S", dateTime, tzd);
|
||||
}
|
||||
else if (certTime->type == V_ASN1_GENERALIZEDTIME)
|
||||
{
|
||||
return DateTimeParser::parse("%Y%m%d%H%M%S", dateTime, tzd);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw NotImplementedException("Unsupported date/time format in notBefore");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool X509Certificate::issuedBy(const X509Certificate& issuerCertificate) const
|
||||
|
||||
Reference in New Issue
Block a user