diff --git a/lib/hx509/cert.c b/lib/hx509/cert.c index 4571b3bdf..ad866a368 100644 --- a/lib/hx509/cert.c +++ b/lib/hx509/cert.c @@ -2248,3 +2248,22 @@ _hx509_cert_get_eku(hx509_context context, } return 0; } + +int +hx509_cert_binary(hx509_context context, hx509_cert c, heim_octet_string *os) +{ + size_t size; + int ret; + + os->data = NULL; + os->length = 0; + + ASN1_MALLOC_ENCODE(Certificate, os->data, os->length, + _hx509_get_cert(c), &size, ret); + if (ret) + return ret; + if (os->length != size) + _hx509_abort("internal ASN.1 encoder error"); + + return ret; +}