From afd0a43725e3a9d6ad3cdb2127141cce98b24277 Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 12 Dec 2014 16:17:53 -0500 Subject: [PATCH] read certificate file --- Reseed.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Reseed.cpp b/Reseed.cpp index e0aadb33..cb851185 100644 --- a/Reseed.cpp +++ b/Reseed.cpp @@ -336,8 +336,12 @@ namespace data std::ifstream s(filename, std::ifstream::binary); if (s.is_open ()) { - std::string cert; - s >> cert; + s.seekg (0, std::ios::end); + size_t len = s.tellg (); + s.seekg (0, std::ios::beg); + char buf[2048]; + s.read (buf, len); + std::string cert (buf, len); // assume file in pem format auto pos1 = cert.find (CERTIFICATE_HEADER); auto pos2 = cert.find (CERTIFICATE_FOOTER); @@ -362,7 +366,8 @@ namespace data // version uint32_t ver; CryptoPP::BERGeneralDecoder context (tbsCert, 0xa0); - CryptoPP::BERDecodeUnsigned(context, ver, CryptoPP::INTEGER, 2, 2); + CryptoPP::BERDecodeUnsigned(context, ver, CryptoPP::INTEGER); + LogPrint (eLogInfo, ver); // serial CryptoPP::Integer serial; serial.BERDecode(tbsCert);