From 09accc91e95dd19db95d59837a7b264dcb4ceef1 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 17 May 2020 17:29:27 +0100 Subject: Improve certificate page styling. --- content/fetchers/about.c | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'content/fetchers') diff --git a/content/fetchers/about.c b/content/fetchers/about.c index 7ce8ab487..6eb882e79 100644 --- a/content/fetchers/about.c +++ b/content/fetchers/about.c @@ -31,6 +31,7 @@ #include #include +#include "netsurf/inttypes.h" #include "netsurf/plot_style.h" #include "utils/log.h" @@ -1172,7 +1173,7 @@ format_certificate_public_key(struct fetch_about_context *ctx, if (public_key->modulus != NULL) { res = ssenddataf(ctx, - "Modulus%s\n", + "Modulus%s\n", public_key->modulus); if (res != NSERROR_OK) { return res; @@ -1224,7 +1225,7 @@ format_certificate_fingerprint(struct fetch_about_context *ctx, if (cert_info->sha256fingerprint != NULL) { res = ssenddataf(ctx, - "SHA-256%s\n", + "SHA-256%s\n", cert_info->sha256fingerprint); if (res != NSERROR_OK) { return res; @@ -1233,7 +1234,7 @@ format_certificate_fingerprint(struct fetch_about_context *ctx, if (cert_info->sha1fingerprint != NULL) { res = ssenddataf(ctx, - "SHA-1%s\n", + "SHA-1%s\n", cert_info->sha1fingerprint); if (res != NSERROR_OK) { return res; @@ -1247,13 +1248,14 @@ format_certificate_fingerprint(struct fetch_about_context *ctx, static nserror format_certificate(struct fetch_about_context *ctx, - struct ns_cert_info *cert_info) + struct ns_cert_info *cert_info, + size_t depth) { nserror res; res = ssenddataf(ctx, - "

Certificate: %s

\n", - cert_info->subject_name.common_name); + "

%s

\n", + depth, cert_info->subject_name.common_name); if (res != NSERROR_OK) { return res; } @@ -1396,14 +1398,40 @@ static bool fetch_about_certificate_handler(struct fetch_about_context *ctx) res = convert_chain_to_cert_info(chain, &cert_info); if (res == NSERROR_OK) { size_t depth; + res = ssenddataf(ctx, "
    \n"); + if (res != NSERROR_OK) { + free_ns_cert_info(cert_info); + goto fetch_about_certificate_handler_aborted; + } + for (depth = 0; depth < chain->depth; depth++) { - res = format_certificate(ctx, cert_info + depth); + res = ssenddataf(ctx, "
  • %s
  • \n", + depth, (cert_info + depth) + ->subject_name + .common_name); if (res != NSERROR_OK) { + free_ns_cert_info(cert_info); + goto fetch_about_certificate_handler_aborted; + } + + } + + for (depth = 0; depth < chain->depth; depth++) { + res = format_certificate(ctx, cert_info + depth, + depth); + if (res != NSERROR_OK) { + free_ns_cert_info(cert_info); goto fetch_about_certificate_handler_aborted; } } free_ns_cert_info(cert_info); + + res = ssenddataf(ctx, "
\n"); + if (res != NSERROR_OK) { + free_ns_cert_info(cert_info); + goto fetch_about_certificate_handler_aborted; + } } else { res = ssenddataf(ctx, "

Invalid certificate data

\n"); -- cgit v1.2.3