59 static void from_istream(std::istream &in,
const std::string &title, CertList *cert_list, CRLList *crl_list)
61 static const char cert_start[] =
"-----BEGIN CERTIFICATE-----";
62 static const char cert_end[] =
"-----END CERTIFICATE-----";
63 static const char crl_start[] =
"-----BEGIN X509 CRL-----";
64 static const char crl_end[] =
"-----END X509 CRL-----";
74 int state = S_OUTSIDE;
75 std::string item =
"";
78 while (std::getline(in, line))
82 if (state == S_OUTSIDE)
84 if (line == cert_start)
87 OPENVPN_THROW(parse_cert_crl_error, title <<
":" << line_num <<
" : not expecting a CERT");
90 else if (line == crl_start)
93 OPENVPN_THROW(parse_cert_crl_error, title <<
":" << line_num <<
" : not expecting a CRL");
97 if (state != S_OUTSIDE)
102 if (state == S_IN_CERT && line == cert_end)
106 cert_list->emplace_back(item, title);
108 catch (
const std::exception &e)
110 OPENVPN_THROW(parse_cert_crl_error, title <<
":" << line_num <<
" : error parsing CERT: " << e.what());
115 if (state == S_IN_CRL && line == crl_end)
119 crl_list->emplace_back(item);
121 catch (
const std::exception &e)
123 OPENVPN_THROW(parse_cert_crl_error, title <<
":" << line_num <<
" : error parsing CRL: " << e.what());
129 if (state != S_OUTSIDE)
130 OPENVPN_THROW(parse_cert_crl_error, title <<
" : CERT/CRL content ended unexpectedly without END marker");