Change return value of OpaqueVal::DoSerialize.

Now it returns a broker::expected<broker::data>, instead of directly
returning a broker::data before. This means that broker::data does no
longer have to be abused to convey error information.

In a way it would be kind of neat to have more fine-granular broker error
types for this use-case - at the moment everything returns
broker::ec::invalid_data, which seems to be the only reasonable choice.
This commit is contained in:
Johanna Amann 2019-06-18 15:23:02 -07:00
parent 53cde131e9
commit e0f10fd6d3
6 changed files with 40 additions and 36 deletions

View file

@ -491,13 +491,13 @@ Val* X509Val::DoClone(CloneState* state)
IMPLEMENT_OPAQUE_VALUE(X509Val)
broker::data X509Val::DoSerialize() const
broker::expected<broker::data> X509Val::DoSerialize() const
{
unsigned char *buf = NULL;
int length = i2d_X509(certificate, &buf);
unsigned char *buf = NULL;
int length = i2d_X509(certificate, &buf);
if ( length < 0 )
return broker::none();
if ( length < 0 )
return broker::ec::invalid_data;
auto d = std::string(reinterpret_cast<const char*>(buf), length);
OPENSSL_free(buf);