aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cli/asn1.cpp11
-rw-r--r--src/cli/cli_exceptions.h3
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") {}