- //cert_parse.hpp
- #include
- #include
- #include
-
- namespace fs = std::filesystem;
-
- enum class CertParseRes{
- ok = 0,
- invalidFile,
- invalidCert,
- invalidPemStr,
- createCertObjFailed,
- loadCertFailed,
- loadPemFailed,
- readX509CertFailed,
- };
-
- class CertParse{
- public:
- CertParse(const fs::path& filePath) : m_filePath(filePath) {}
- CertParse(const std::string& pemStr) : m_certPemStr(pemStr) {}
- CertParse() = delete;
- CertParse(const CertParse&) = delete;
- CertParse(CertParse&&) = delete;
- CertParse& operator=(const CertParse&) = delete;
- CertParse& operator=(CertParse&&) = delete;
- ~CertParse() = default;
-
- public:
- CertParseRes doParse();
- std::string pErr(CertParseRes res);
- void print();
-
- public:
- int m_version{0};
- std::string m_issue;
- std::string m_issuerCommonName;