Return error if certificate expiry date is beyond year 2038

Any certificate which is uploaded with expiry year greater than 2038
causes the exipry date to be set to time before 1970.

time_t is used in calculation of expirty date based on seconds from
epoch. As time_t is defined as int32 any time beyond 2038 causes
integer overflow and generates a negtive number. When the negative
number is used in time calculation it generates year before 1970.

Modified to return error if the seconds computed for expiry date
is beyond INT_MAX.

This change is required till kernel changes time_t to use  64 bit value.

Tested:
Mar 12 11:14:38 xx phosphor-certificate-manager[520]: Certificate install
Mar 12 11:14:38 xx phosphor-certificate-manager[520]: Certificate expiry date is
beyond year 2038
Mar 12 11:14:38 xx phosphor-certificate-manager[520]: Invalid certificate file.
"MESSAGE" : "Certificate expiry date is beyond year 2038",
"PRIORITY" : "3",
"SECONDS" : "2366947077",

Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
Change-Id: Icb926fe6eebb2ce896ccde2527b7494896653f58
2 files changed
tree: 5e4203e083f90f3cde2e91cff1ef1155a843dae0
  1. test/
  2. .clang-format
  3. .gitignore
  4. argument.cpp
  5. argument.hpp
  6. bootstrap.sh
  7. certificate.cpp
  8. certificate.hpp
  9. certs_manager.cpp
  10. certs_manager.hpp
  11. configure.ac
  12. csr.cpp
  13. csr.hpp
  14. LICENSE
  15. mainapp.cpp
  16. MAINTAINERS
  17. Makefile.am
  18. README.md
  19. watch.cpp
  20. watch.hpp
README.md

phosphor-certificate-manager

Certificate management allows to replace the existing certificate and private key file with another (possibly CA signed) Certificate key file. Certificate management allows the user to install both the server and client certificates.

To Build

To build this package, do the following steps:

    1. ./bootstrap.sh
    2. ./configure ${CONFIGURE_FLAGS}
    3. make

To clean the repository run `./bootstrap.sh clean`.