summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/certificate.cc2
-rw-r--r--test/certificates_test.cc20
2 files changed, 22 insertions, 0 deletions
diff --git a/src/certificate.cc b/src/certificate.cc
index 9f8499c9..2e33907d 100644
--- a/src/certificate.cc
+++ b/src/certificate.cc
@@ -354,6 +354,8 @@ convert_time (ASN1_TIME const * time)
t.tm_year -= 1900;
}
+ t.tm_mon--;
+
return t;
}
diff --git a/test/certificates_test.cc b/test/certificates_test.cc
index fccc667c..692b169e 100644
--- a/test/certificates_test.cc
+++ b/test/certificates_test.cc
@@ -258,3 +258,23 @@ BOOST_AUTO_TEST_CASE (certificate_chain_from_string)
dcp::CertificateChain b (dcp::file_to_string ("test/ref/crypt/leaf.signed.pem"));
BOOST_CHECK_EQUAL (b.root_to_leaf().size(), 1);
}
+
+/** Check not_before and not_after */
+BOOST_AUTO_TEST_CASE (certificate_not_before_after)
+{
+ dcp::Certificate c (dcp::file_to_string("test/ref/crypt/ca.self-signed.pem"));
+ struct tm not_before = c.not_before();
+ BOOST_CHECK_EQUAL (not_before.tm_sec, 8);
+ BOOST_CHECK_EQUAL (not_before.tm_min, 20);
+ BOOST_CHECK_EQUAL (not_before.tm_hour, 13);
+ BOOST_CHECK_EQUAL (not_before.tm_mday, 5);
+ BOOST_CHECK_EQUAL (not_before.tm_mon, 5);
+ BOOST_CHECK_EQUAL (not_before.tm_year, 115);
+ struct tm not_after = c.not_after();
+ BOOST_CHECK_EQUAL (not_after.tm_sec, 8);
+ BOOST_CHECK_EQUAL (not_after.tm_min, 20);
+ BOOST_CHECK_EQUAL (not_after.tm_hour, 13);
+ BOOST_CHECK_EQUAL (not_after.tm_mday, 2);
+ BOOST_CHECK_EQUAL (not_after.tm_mon, 5);
+ BOOST_CHECK_EQUAL (not_after.tm_year, 125);
+}