13 (
"https-client-root-cert", boost::program_options::value<vector<string>>()->composing()->multitoken(),
14 "PEM encoded trusted root certificate (or path to file containing one) used to validate any TLS connections made. (may specify multiple times)\n")
15 (
"https-client-validate-peers", boost::program_options::value<bool>()->default_value(
true),
16 "true: validate that the peer certificates are valid and trusted, false: ignore cert errors")
23 if( options.count(
"https-client-root-cert" )) {
24 const std::vector<std::string> root_pems = options[
"https-client-root-cert"].as<std::vector<std::string>>();
25 for(
const auto& root_pem : root_pems ) {
26 std::string pem_str = root_pem;
27 if( !boost::algorithm::starts_with( pem_str,
"-----BEGIN CERTIFICATE-----\n" )) {
29 auto infile = std::ifstream( pem_str );
30 std::stringstream sstr;
31 sstr << infile.rdbuf();
33 SYS_ASSERT( boost::algorithm::starts_with( pem_str,
"-----BEGIN CERTIFICATE-----\n" ),
34 chain::invalid_http_client_root_cert,
35 "File does not appear to be a PEM encoded certificate" );
36 }
catch (
const std::bad_alloc& ) {
38 }
catch (
const boost::interprocess::bad_alloc& ) {
42 }
catch (
const std::exception& e ) {
48 my->add_cert( pem_str );
49 }
catch (
const std::bad_alloc& ) {
51 }
catch (
const boost::interprocess::bad_alloc& ) {
55 }
catch (
const std::exception& e ) {
61 my->set_verify_peers( options.at(
"https-client-validate-peers" ).as<
bool>());