From 9de742560c0239ad62a254520c305f2526effbb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Tue, 26 Jun 2007 12:18:33 +0000 Subject: [PATCH] Move _hx509_request_print here. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21335 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/hx509/req.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/lib/hx509/req.c b/lib/hx509/req.c index 91288c941..4e71a45d0 100644 --- a/lib/hx509/req.c +++ b/lib/hx509/req.c @@ -215,3 +215,58 @@ out: return ret; } + +int +_hx509_request_print(hx509_context context, FILE *f, const void *data, size_t len) +{ + CertificationRequest req; + CertificationRequestInfo *rinfo; + size_t size; + int ret; + + ret = decode_CertificationRequest(data, len, &req, &size); + if (ret) { + hx509_set_error_string(context, 0, ret, "Failed to decode request"); + return ret; + } + + rinfo = &req.certificationRequestInfo; + + { + char *subject; + hx509_name n; + + ret = _hx509_name_from_Name(&rinfo->subject, &n); + if (ret) { + hx509_set_error_string(context, 0, ret, "Failed to extract name"); + free_CertificationRequest(&req); + return ret; + } + ret = hx509_name_to_string(n, &subject); + hx509_name_free(&n); + if (ret) { + hx509_set_error_string(context, 0, ret, "Failed to print name"); + free_CertificationRequest(&req); + return ret; + } + + fprintf(f, "name: %s\n", subject); + free(subject); + } + + if (rinfo->attributes && rinfo->attributes->len) { + int j; + + fprintf(f, "Attributes:\n"); + + for (j = 0; j < rinfo->attributes->len; j++) { + char *str; + hx509_oid_sprint(&rinfo->attributes->val[j].type, &str); + fprintf(f, "\toid: %s\n", str); + free(str); + } + } + free_CertificationRequest(&req); + return 0; +} +