diff options
author | Jack Lloyd <[email protected]> | 2017-11-21 01:32:45 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-11-21 01:32:45 -0500 |
commit | 103479a7ca4d2a2df18201bf5ee0f6acc2af9cf3 (patch) | |
tree | fbb76d2e8099fc76e84dcce490acd5a265208853 /src | |
parent | 41990691884d7cc04d9045442f7c01419faf947b (diff) |
Allow building asn1print even if PEM is disabled
Just throws if --pem arg is used.
Diffstat (limited to 'src')
-rw-r--r-- | src/cli/asn1.cpp | 11 | ||||
-rw-r--r-- | src/cli/cli_exceptions.h | 3 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/cli/asn1.cpp b/src/cli/asn1.cpp index 6460d5587..ca8f5f89f 100644 --- a/src/cli/asn1.cpp +++ b/src/cli/asn1.cpp @@ -6,11 +6,14 @@ #include "cli.h" -#if defined(BOTAN_HAS_ASN1) && defined(BOTAN_HAS_PEM_CODEC) +#if defined(BOTAN_HAS_ASN1) -#include <botan/pem.h> #include <botan/asn1_print.h> +#if defined(BOTAN_HAS_PEM_CODEC) + #include <botan/pem.h> +#endif + namespace Botan_CLI { class ASN1_Printer final : public Command @@ -26,8 +29,12 @@ class ASN1_Printer final : public Command if(flag_set("pem")) { +#if defined(BOTAN_HAS_PEM_CODEC) std::string pem_label; contents = unlock(Botan::PEM_Code::decode(slurp_file_as_str(input), pem_label)); +#else + throw CLI_Error_Unsupported("PEM decoding not available in this build"); +#endif } else { diff --git a/src/cli/cli_exceptions.h b/src/cli/cli_exceptions.h index ed7be3137..38459b8dd 100644 --- a/src/cli/cli_exceptions.h +++ b/src/cli/cli_exceptions.h @@ -34,6 +34,9 @@ class CLI_Usage_Error : public CLI_Error class CLI_Error_Unsupported : public CLI_Error { public: + + CLI_Error_Unsupported(const std::string& msg) : CLI_Error(msg) {} + CLI_Error_Unsupported(const std::string& what, const std::string& who) : CLI_Error(what + " with '" + who + "' unsupported or not available") {} |