Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/1a25234f20b6c634024196143677c14e8142576c
...commit
http://git.netsurf-browser.org/netsurf.git/commit/1a25234f20b6c634024196143677c14e8142576c
...tree
http://git.netsurf-browser.org/netsurf.git/tree/1a25234f20b6c634024196143677c14e8142576c
The branch, master has been updated
via 1a25234f20b6c634024196143677c14e8142576c (commit)
from 52bfae17822d289dcf16566acfa3eac2539d66d5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=1a25234f20b6c634024196143677c14e8142576c
commit 1a25234f20b6c634024196143677c14e8142576c
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
implement browser_window_show_certificates
diff --git a/desktop/browser_window.c b/desktop/browser_window.c
index e128852..f705ce9 100644
--- a/desktop/browser_window.c
+++ b/desktop/browser_window.c
@@ -35,6 +35,7 @@
#include <strings.h>
#include <math.h>
#include <nsutils/time.h>
+#include <nsutils/base64.h>
#include "utils/corestrings.h"
#include "utils/log.h"
@@ -4764,9 +4765,69 @@ nserror browser_window_show_cookies(
}
/* Exported interface, documented in browser_window.h */
-nserror browser_window_show_certificates(
- const struct browser_window *bw)
+nserror browser_window_show_certificates(const struct browser_window *bw)
{
- /** \todo Implement show certificates */
- return NSERROR_OK;
+ nserror res;
+ nsurl *url;
+ size_t allocsize;
+ size_t urlstrlen;
+ uint8_t *urlstr;
+ size_t depth;
+
+ if (bw->current_cert_chain == NULL) {
+ return NSERROR_NOT_FOUND;
+ }
+
+ allocsize = 20;
+ for (depth = 0; depth < bw->current_cert_chain->depth; depth++) {
+ allocsize += 7; /* allow for &cert= */
+ allocsize += 4 *
((bw->current_cert_chain->certs[depth].der_length + 2) / 3);
+ }
+
+ urlstr = malloc(allocsize);
+ if (urlstr == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ urlstrlen = snprintf((char *)urlstr, allocsize, "about:certificate");
+ for (depth = 0; depth < bw->current_cert_chain->depth; depth++) {
+ nsuerror nsures;
+ size_t output_length;
+
+ urlstrlen += snprintf((char *)urlstr + urlstrlen,
+ allocsize - urlstrlen,
+ "&cert=");
+
+ output_length = allocsize - urlstrlen;
+ nsures = nsu_base64_encode_url(
+ bw->current_cert_chain->certs[depth].der,
+ bw->current_cert_chain->certs[depth].der_length,
+ (uint8_t *)urlstr + urlstrlen,
+ &output_length);
+ if (nsures != NSUERROR_OK) {
+ free(urlstr);
+ return (nserror)nsures;
+ }
+ urlstrlen += output_length;
+ }
+ urlstr[17] = '?';
+ urlstr[urlstrlen] = 0;
+
+ res = nsurl_create((const char *)urlstr, &url);
+ free(urlstr);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ res = browser_window_create(BW_CREATE_HISTORY |
+ BW_CREATE_FOREGROUND |
+ BW_CREATE_TAB,
+ url,
+ NULL,
+ bw,
+ NULL);
+
+ nsurl_unref(url);
+
+ return res;
}
-----------------------------------------------------------------------
Summary of changes:
desktop/browser_window.c | 69 +++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 65 insertions(+), 4 deletions(-)
diff --git a/desktop/browser_window.c b/desktop/browser_window.c
index e128852..f705ce9 100644
--- a/desktop/browser_window.c
+++ b/desktop/browser_window.c
@@ -35,6 +35,7 @@
#include <strings.h>
#include <math.h>
#include <nsutils/time.h>
+#include <nsutils/base64.h>
#include "utils/corestrings.h"
#include "utils/log.h"
@@ -4764,9 +4765,69 @@ nserror browser_window_show_cookies(
}
/* Exported interface, documented in browser_window.h */
-nserror browser_window_show_certificates(
- const struct browser_window *bw)
+nserror browser_window_show_certificates(const struct browser_window *bw)
{
- /** \todo Implement show certificates */
- return NSERROR_OK;
+ nserror res;
+ nsurl *url;
+ size_t allocsize;
+ size_t urlstrlen;
+ uint8_t *urlstr;
+ size_t depth;
+
+ if (bw->current_cert_chain == NULL) {
+ return NSERROR_NOT_FOUND;
+ }
+
+ allocsize = 20;
+ for (depth = 0; depth < bw->current_cert_chain->depth; depth++) {
+ allocsize += 7; /* allow for &cert= */
+ allocsize += 4 *
((bw->current_cert_chain->certs[depth].der_length + 2) / 3);
+ }
+
+ urlstr = malloc(allocsize);
+ if (urlstr == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ urlstrlen = snprintf((char *)urlstr, allocsize, "about:certificate");
+ for (depth = 0; depth < bw->current_cert_chain->depth; depth++) {
+ nsuerror nsures;
+ size_t output_length;
+
+ urlstrlen += snprintf((char *)urlstr + urlstrlen,
+ allocsize - urlstrlen,
+ "&cert=");
+
+ output_length = allocsize - urlstrlen;
+ nsures = nsu_base64_encode_url(
+ bw->current_cert_chain->certs[depth].der,
+ bw->current_cert_chain->certs[depth].der_length,
+ (uint8_t *)urlstr + urlstrlen,
+ &output_length);
+ if (nsures != NSUERROR_OK) {
+ free(urlstr);
+ return (nserror)nsures;
+ }
+ urlstrlen += output_length;
+ }
+ urlstr[17] = '?';
+ urlstr[urlstrlen] = 0;
+
+ res = nsurl_create((const char *)urlstr, &url);
+ free(urlstr);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ res = browser_window_create(BW_CREATE_HISTORY |
+ BW_CREATE_FOREGROUND |
+ BW_CREATE_TAB,
+ url,
+ NULL,
+ bw,
+ NULL);
+
+ nsurl_unref(url);
+
+ return res;
}
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org