aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/x509/x509_crl.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-12-04 14:00:47 -0500
committerJack Lloyd <[email protected]>2017-12-04 14:00:47 -0500
commit697fdc8fcb7f4ada4699ccad80def4673270d133 (patch)
tree5b2ec8652a20d7e0c0b74f328958818fafaa14b4 /src/lib/x509/x509_crl.cpp
parentd3c1f3ba1a9d03ff8e84f0044ee3854804fac86b (diff)
Support uninitialized certificate objects
Issued raised by @securitykernel on Slack, there was no non-hacky way to decode a list of certificate objects because creating an uninitialized one wasn't allowed. However after #884 that got much closer to being viable, this is the last pieces.
Diffstat (limited to 'src/lib/x509/x509_crl.cpp')
-rw-r--r--src/lib/x509/x509_crl.cpp41
1 files changed, 23 insertions, 18 deletions
diff --git a/src/lib/x509/x509_crl.cpp b/src/lib/x509/x509_crl.cpp
index 4a6c4249a..4fa5df44f 100644
--- a/src/lib/x509/x509_crl.cpp
+++ b/src/lib/x509/x509_crl.cpp
@@ -25,31 +25,34 @@ struct CRL_Data
std::vector<uint8_t> m_auth_key_id;
};
-/*
-* Load a X.509 CRL
-*/
-X509_CRL::X509_CRL(DataSource& in) :
- X509_Object(in, "X509 CRL/CRL")
+std::string X509_CRL::PEM_label() const
{
- do_decode();
+ return "X509 CRL";
}
-#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
-/*
-* Load a X.509 CRL
-*/
-X509_CRL::X509_CRL(const std::string& fsname) :
- X509_Object(fsname, "CRL/X509 CRL")
+std::vector<std::string> X509_CRL::alternate_PEM_labels() const
{
- do_decode();
+ return { "CRL" };
+ }
+
+X509_CRL::X509_CRL(DataSource& src)
+ {
+ load_data(src);
+ }
+
+X509_CRL::X509_CRL(const std::vector<uint8_t>& vec)
+ {
+ DataSource_Memory src(vec.data(), vec.size());
+ load_data(src);
}
-#endif
-X509_CRL::X509_CRL(const std::vector<uint8_t>& in) :
- X509_Object(in, "CRL/X509 CRL")
+#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
+X509_CRL::X509_CRL(const std::string& fsname)
{
- do_decode();
+ DataSource_Stream src(fsname);
+ load_data(src);
}
+#endif
X509_CRL::X509_CRL(const X509_DN& issuer,
const X509_Time& this_update,
@@ -174,7 +177,9 @@ void X509_CRL::force_decode()
const CRL_Data& X509_CRL::data() const
{
if(!m_data)
- throw Decoding_Error("Error decoding X509 CRL");
+ {
+ throw Invalid_State("X509_CRL uninitialized");
+ }
return *m_data.get();
}