diff options
author | Tomasz Frydrych <[email protected]> | 2017-05-01 15:03:52 +0200 |
---|---|---|
committer | Tomasz Frydrych <[email protected]> | 2017-05-01 15:03:52 +0200 |
commit | 87c0fae706140b0a2a7a3fda9dd813474172fa2a (patch) | |
tree | 28930efab4d290dcebb89666d46050edd06703fd /src/cli/x509.cpp | |
parent | 29cc6bebe132a34f882d450b35a69bf71bb3e27b (diff) |
Reformat code with astyle + fix code style
Diffstat (limited to 'src/cli/x509.cpp')
-rw-r--r-- | src/cli/x509.cpp | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/src/cli/x509.cpp b/src/cli/x509.cpp index c1c5f6955..e2163b987 100644 --- a/src/cli/x509.cpp +++ b/src/cli/x509.cpp @@ -16,7 +16,7 @@ #include <botan/x509self.h> #if defined(BOTAN_HAS_OCSP) - #include <botan/ocsp.h> + #include <botan/ocsp.h> #endif namespace Botan_CLI { @@ -24,8 +24,9 @@ namespace Botan_CLI { class Sign_Cert final : public Command { public: - Sign_Cert() : Command("sign_cert --ca-key-pass= --hash=SHA-256 " - "--duration=365 ca_cert ca_key pkcs10_req") {} + Sign_Cert() + : Command("sign_cert --ca-key-pass= --hash=SHA-256 " + "--duration=365 ca_cert ca_key pkcs10_req") {} void go() override { @@ -34,18 +35,17 @@ class Sign_Cert final : public Command if(flag_set("ca_key_pass")) { - key.reset(Botan::PKCS8::load_key(get_arg("ca_key"), - rng(), - get_arg("ca_key_pass"))); + key.reset(Botan::PKCS8::load_key(get_arg("ca_key"), rng(), get_arg("ca_key_pass"))); } else { - key.reset(Botan::PKCS8::load_key(get_arg("ca_key"), - rng())); + key.reset(Botan::PKCS8::load_key(get_arg("ca_key"), rng())); } if(!key) + { throw CLI_Error("Failed to load key from " + get_arg("ca_key")); + } Botan::X509_CA ca(ca_cert, *key, get_arg("hash"), rng()); @@ -59,8 +59,7 @@ class Sign_Cert final : public Command Botan::X509_Time end_time(now + days(get_arg_sz("duration"))); - Botan::X509_Certificate new_cert = ca.sign_request(req, rng(), - start_time, end_time); + Botan::X509_Certificate new_cert = ca.sign_request(req, rng(), start_time, end_time); output() << new_cert.PEM_encode(); } @@ -96,7 +95,9 @@ class Cert_Info final : public Command catch(Botan::Exception& e) { if(!in.end_of_data()) + { output() << "X509_Certificate parsing failed " << e.what() << "\n"; + } } } } @@ -128,8 +129,7 @@ class OCSP_Check final : public Command } else { - output() << "OCSP check failed " << - Botan::Path_Validation_Result::status_string(status) << "\n"; + output() << "OCSP check failed " << Botan::Path_Validation_Result::status_string(status) << "\n"; } } }; @@ -148,7 +148,7 @@ class Cert_Verify final : public Command Botan::X509_Certificate subject_cert(get_arg("subject")); Botan::Certificate_Store_In_Memory trusted; - for(auto&& certfile : get_arg_list("ca_certs")) + for(auto const& certfile : get_arg_list("ca_certs")) { trusted.add_certificate(Botan::X509_Certificate(certfile)); } @@ -176,18 +176,18 @@ BOTAN_REGISTER_COMMAND("cert_verify", Cert_Verify); class Gen_Self_Signed final : public Command { public: - Gen_Self_Signed() : Command("gen_self_signed key CN --country= --dns= " - "--organization= --email= --key-pass= --ca --hash=SHA-256") {} + Gen_Self_Signed() + : Command("gen_self_signed key CN --country= --dns= " + "--organization= --email= --key-pass= --ca --hash=SHA-256") {} void go() override { - std::unique_ptr<Botan::Private_Key> key( - Botan::PKCS8::load_key(get_arg("key"), - rng(), - get_arg("key-pass"))); + std::unique_ptr<Botan::Private_Key> key(Botan::PKCS8::load_key(get_arg("key"), rng(), get_arg("key-pass"))); if(!key) + { throw CLI_Error("Failed to load key from " + get_arg("key")); + } Botan::X509_Cert_Options opts; @@ -198,10 +198,11 @@ class Gen_Self_Signed final : public Command opts.dns = get_arg("dns"); if(flag_set("ca")) + { opts.CA_key(); + } - Botan::X509_Certificate cert = - Botan::X509::create_self_signed_cert(opts, *key, get_arg("hash"), rng()); + Botan::X509_Certificate cert = Botan::X509::create_self_signed_cert(opts, *key, get_arg("hash"), rng()); output() << cert.PEM_encode(); } @@ -212,18 +213,18 @@ BOTAN_REGISTER_COMMAND("gen_self_signed", Gen_Self_Signed); class Generate_PKCS10 final : public Command { public: - Generate_PKCS10() : Command("gen_pkcs10 key CN --country= --organization= " - "--email= --key-pass= --hash=SHA-256") {} + Generate_PKCS10() + : Command("gen_pkcs10 key CN --country= --organization= " + "--email= --key-pass= --hash=SHA-256") {} void go() override { - std::unique_ptr<Botan::Private_Key> key( - Botan::PKCS8::load_key(get_arg("key"), - rng(), - get_arg("key-pass"))); + std::unique_ptr<Botan::Private_Key> key(Botan::PKCS8::load_key(get_arg("key"), rng(), get_arg("key-pass"))); if(!key) + { throw CLI_Error("Failed to load key from " + get_arg("key")); + } Botan::X509_Cert_Options opts; @@ -232,10 +233,7 @@ class Generate_PKCS10 final : public Command opts.organization = get_arg("organization"); opts.email = get_arg("email"); - Botan::PKCS10_Request req = - Botan::X509::create_cert_req(opts, *key, - get_arg("hash"), - rng()); + Botan::PKCS10_Request req = Botan::X509::create_cert_req(opts, *key, get_arg("hash"), rng()); output() << req.PEM_encode(); } |