aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-10-02 14:14:44 -0400
committerJack Lloyd <[email protected]>2016-10-02 14:14:44 -0400
commitab2842d6f28680b1cac18d5ff6b70b395d1ffb65 (patch)
treec350494e6f0ee0c5ad492692c57d9212509eaa1e /src
parentcccca06d3916a4eeb9c19f69ae44074abde7e460 (diff)
Have cli cert_info parse multiple certs from file
Diffstat (limited to 'src')
-rw-r--r--src/cli/x509.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/cli/x509.cpp b/src/cli/x509.cpp
index 90979aa53..e65398439 100644
--- a/src/cli/x509.cpp
+++ b/src/cli/x509.cpp
@@ -71,12 +71,34 @@ BOTAN_REGISTER_COMMAND("sign_cert", Sign_Cert);
class Cert_Info final : public Command
{
public:
- Cert_Info() : Command("cert_info file") {}
+ Cert_Info() : Command("cert_info --ber file") {}
void go() override
{
- Botan::X509_Certificate cert(get_arg("file"));
- output() << cert.to_string() << "\n";
+ Botan::DataSource_Stream in(get_arg("file"), flag_set("ber"));
+
+ while(!in.end_of_data())
+ {
+ try
+ {
+ Botan::X509_Certificate cert(in);
+
+ try
+ {
+ output() << cert.to_string() << std::endl;
+ }
+ catch(Botan::Exception& e)
+ {
+ // to_string failed - report the exception and continue
+ output() << "X509_Certificate::to_string failed: " << e.what() << "\n";
+ }
+ }
+ catch(Botan::Exception& e)
+ {
+ if(!in.end_of_data())
+ output() << "X509_Certificate parsing failed " << e.what() << "\n";
+ }
+ }
}
};