2013-08-12 01:11:05 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2009 Paul Blokus <paul_pl@users.sourceforge.net>
|
|
|
|
* Copyright 2013 Michael Drake <tlsa@netsurf-browser.org>
|
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2017-03-02 02:47:27 +03:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* SSL Certificate verification UI implementation
|
2013-08-12 01:11:05 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "content/fetch.h"
|
|
|
|
#include "content/urldb.h"
|
2014-02-03 21:56:24 +04:00
|
|
|
#include "content/hlcache.h"
|
2013-08-12 01:11:05 +04:00
|
|
|
#include "desktop/sslcert_viewer.h"
|
|
|
|
#include "desktop/treeview.h"
|
|
|
|
#include "utils/messages.h"
|
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/utils.h"
|
|
|
|
|
2017-03-02 02:47:27 +03:00
|
|
|
/**
|
|
|
|
* ssl certificate viewer data fields
|
|
|
|
*/
|
2013-08-12 01:11:05 +04:00
|
|
|
enum sslcert_viewer_field {
|
|
|
|
SSLCERT_V_SUBJECT,
|
|
|
|
SSLCERT_V_SERIAL,
|
|
|
|
SSLCERT_V_TYPE,
|
|
|
|
SSLCERT_V_VALID_UNTIL,
|
|
|
|
SSLCERT_V_VALID_FROM,
|
|
|
|
SSLCERT_V_VERSION,
|
|
|
|
SSLCERT_V_ISSUER,
|
|
|
|
SSLCERT_V_CERTIFICATES,
|
|
|
|
SSLCERT_V_N_FIELDS
|
|
|
|
};
|
|
|
|
|
2017-03-02 02:47:27 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ssl certificate verification context.
|
|
|
|
*/
|
2013-08-12 01:11:05 +04:00
|
|
|
struct sslcert_session_data {
|
2014-07-17 18:20:38 +04:00
|
|
|
struct ssl_cert_info *certs; /**< Certificates */
|
2013-08-12 01:11:05 +04:00
|
|
|
unsigned long num; /**< Number of certificates in chain */
|
|
|
|
nsurl *url; /**< The url of the certificate */
|
|
|
|
llcache_query_response cb; /**< Cert accept/reject callback */
|
|
|
|
void *cbpw; /**< Context passed to callback */
|
|
|
|
|
|
|
|
treeview *tree; /**< The treeview object */
|
|
|
|
struct treeview_field_desc fields[SSLCERT_V_N_FIELDS];
|
|
|
|
};
|
|
|
|
|
2017-03-02 02:47:27 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ssl certificate tree entry
|
|
|
|
*/
|
2013-08-12 01:11:05 +04:00
|
|
|
struct sslcert_entry {
|
|
|
|
treeview_node *entry;
|
|
|
|
char version[24];
|
|
|
|
char serial[24];
|
|
|
|
char type[24];
|
|
|
|
struct treeview_field_data data[SSLCERT_V_N_FIELDS - 1];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2017-03-02 02:47:27 +03:00
|
|
|
* Free a ssl certificate viewer entry's treeview field data.
|
2013-08-12 01:11:05 +04:00
|
|
|
*
|
2017-03-02 02:47:27 +03:00
|
|
|
* \param e Entry to free data from
|
2013-08-12 01:11:05 +04:00
|
|
|
*/
|
2017-03-02 02:47:27 +03:00
|
|
|
static void sslcert_viewer_free_treeview_field_data(struct sslcert_entry *e)
|
2013-08-12 01:11:05 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Build a sslcert viewer treeview field from given text
|
|
|
|
*
|
2017-03-02 02:47:27 +03:00
|
|
|
* \param field SSL certificate treeview field to build
|
|
|
|
* \param data SSL certificate entry field data to set
|
|
|
|
* \param value Text to set in field, ownership yielded
|
|
|
|
* \param ssl_d SSL certificate session data
|
2013-08-12 01:11:05 +04:00
|
|
|
* \return NSERROR_OK on success, appropriate error otherwise
|
|
|
|
*/
|
2017-03-02 02:47:27 +03:00
|
|
|
static inline nserror
|
|
|
|
sslcert_viewer_field_builder(enum sslcert_viewer_field field,
|
|
|
|
struct treeview_field_data *data,
|
|
|
|
const char *value,
|
|
|
|
struct sslcert_session_data *ssl_d)
|
2013-08-12 01:11:05 +04:00
|
|
|
{
|
|
|
|
data->field = ssl_d->fields[field].field;
|
|
|
|
data->value = value;
|
|
|
|
data->value_len = (value != NULL) ? strlen(value) : 0;
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a sslcert viewer entry's data from the certificate.
|
|
|
|
*
|
2017-03-02 02:47:27 +03:00
|
|
|
* \param e Entry to set up
|
|
|
|
* \param cert Data associated with entry's certificate
|
|
|
|
* \param ssl_d SSL certificate session data
|
2013-08-12 01:11:05 +04:00
|
|
|
* \return NSERROR_OK on success, appropriate error otherwise
|
|
|
|
*/
|
2017-03-02 02:47:27 +03:00
|
|
|
static nserror
|
|
|
|
sslcert_viewer_set_treeview_field_data(struct sslcert_entry *e,
|
|
|
|
const struct ssl_cert_info *cert,
|
|
|
|
struct sslcert_session_data *ssl_d)
|
2013-08-12 01:11:05 +04:00
|
|
|
{
|
|
|
|
unsigned int written;
|
|
|
|
|
|
|
|
assert(e != NULL);
|
|
|
|
assert(cert != NULL);
|
|
|
|
assert(ssl_d != NULL);
|
|
|
|
|
|
|
|
/* Set the fields up */
|
|
|
|
sslcert_viewer_field_builder(SSLCERT_V_SUBJECT,
|
2017-03-02 02:47:27 +03:00
|
|
|
&e->data[SSLCERT_V_SUBJECT],
|
|
|
|
cert->subject, ssl_d);
|
2013-08-12 01:11:05 +04:00
|
|
|
|
|
|
|
written = snprintf(e->serial, sizeof(e->serial), "%li", cert->serial);
|
|
|
|
assert(written < sizeof(e->serial));
|
|
|
|
sslcert_viewer_field_builder(SSLCERT_V_SERIAL,
|
2017-03-02 02:47:27 +03:00
|
|
|
&e->data[SSLCERT_V_SERIAL],
|
|
|
|
e->serial, ssl_d);
|
2013-08-12 01:11:05 +04:00
|
|
|
|
|
|
|
written = snprintf(e->type, sizeof(e->type), "%i", cert->cert_type);
|
|
|
|
assert(written < sizeof(e->type));
|
|
|
|
sslcert_viewer_field_builder(SSLCERT_V_TYPE,
|
2017-03-02 02:47:27 +03:00
|
|
|
&e->data[SSLCERT_V_TYPE],
|
|
|
|
e->type, ssl_d);
|
2013-08-12 01:11:05 +04:00
|
|
|
|
|
|
|
sslcert_viewer_field_builder(SSLCERT_V_VALID_UNTIL,
|
2017-03-02 02:47:27 +03:00
|
|
|
&e->data[SSLCERT_V_VALID_UNTIL],
|
|
|
|
cert->not_after, ssl_d);
|
2013-08-12 01:11:05 +04:00
|
|
|
|
|
|
|
sslcert_viewer_field_builder(SSLCERT_V_VALID_FROM,
|
2017-03-02 02:47:27 +03:00
|
|
|
&e->data[SSLCERT_V_VALID_FROM],
|
|
|
|
cert->not_before, ssl_d);
|
2013-08-12 01:11:05 +04:00
|
|
|
|
|
|
|
written = snprintf(e->version, sizeof(e->version),
|
2017-03-02 02:47:27 +03:00
|
|
|
"%li", cert->version);
|
2013-08-12 01:11:05 +04:00
|
|
|
assert(written < sizeof(e->version));
|
|
|
|
sslcert_viewer_field_builder(SSLCERT_V_VERSION,
|
2017-03-02 02:47:27 +03:00
|
|
|
&e->data[SSLCERT_V_VERSION],
|
|
|
|
e->version, ssl_d);
|
2013-08-12 01:11:05 +04:00
|
|
|
|
|
|
|
sslcert_viewer_field_builder(SSLCERT_V_ISSUER,
|
2017-03-02 02:47:27 +03:00
|
|
|
&e->data[SSLCERT_V_ISSUER],
|
|
|
|
cert->issuer, ssl_d);
|
2013-08-12 01:11:05 +04:00
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a treeview node for a certificate
|
|
|
|
*
|
2017-03-02 02:47:27 +03:00
|
|
|
* \param ssl_d SSL certificate session data
|
|
|
|
* \param n Number of SSL certificate in chain, to make node for
|
|
|
|
* \return NSERROR_OK on success otherwise error code.
|
2013-08-12 01:11:05 +04:00
|
|
|
*/
|
2017-03-02 02:47:27 +03:00
|
|
|
static nserror
|
|
|
|
sslcert_viewer_create_node(struct sslcert_session_data *ssl_d, int n)
|
2013-08-12 01:11:05 +04:00
|
|
|
{
|
|
|
|
struct sslcert_entry *e;
|
|
|
|
const struct ssl_cert_info *cert = &(ssl_d->certs[n]);
|
|
|
|
nserror err;
|
|
|
|
|
|
|
|
/* Create new certificate viewer entry */
|
|
|
|
e = malloc(sizeof(struct sslcert_entry));
|
|
|
|
if (e == NULL) {
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = sslcert_viewer_set_treeview_field_data(e, cert, ssl_d);
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
free(e);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the new treeview node */
|
|
|
|
err = treeview_create_node_entry(ssl_d->tree, &(e->entry),
|
2017-03-02 02:47:27 +03:00
|
|
|
NULL, TREE_REL_FIRST_CHILD,
|
|
|
|
e->data, e, TREE_OPTION_NONE);
|
2013-08-12 01:11:05 +04:00
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
sslcert_viewer_free_treeview_field_data(e);
|
|
|
|
free(e);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2017-03-02 02:47:27 +03:00
|
|
|
* Initialise the treeview entry fields
|
2013-08-12 01:11:05 +04:00
|
|
|
*
|
2017-03-02 02:47:27 +03:00
|
|
|
* \param ssl_d SSL certificate session data
|
|
|
|
* \return NSERROR_OK on success otherwise error code.
|
2013-08-12 01:11:05 +04:00
|
|
|
*/
|
|
|
|
static nserror sslcert_init_entry_fields(struct sslcert_session_data *ssl_d)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const char *label;
|
|
|
|
|
|
|
|
for (i = 0; i < SSLCERT_V_N_FIELDS; i++)
|
|
|
|
ssl_d->fields[i].field = NULL;
|
|
|
|
|
|
|
|
ssl_d->fields[SSLCERT_V_SUBJECT].flags = TREE_FLAG_DEFAULT;
|
|
|
|
label = "TreeviewLabelSubject";
|
|
|
|
label = messages_get(label);
|
|
|
|
if (lwc_intern_string(label, strlen(label),
|
2017-03-02 02:47:27 +03:00
|
|
|
&ssl_d->fields[SSLCERT_V_SUBJECT].field) !=
|
|
|
|
lwc_error_ok) {
|
2013-08-12 01:11:05 +04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
ssl_d->fields[SSLCERT_V_SERIAL].flags = TREE_FLAG_SHOW_NAME;
|
|
|
|
label = "TreeviewLabelSerial";
|
|
|
|
label = messages_get(label);
|
|
|
|
if (lwc_intern_string(label, strlen(label),
|
2017-03-02 02:47:27 +03:00
|
|
|
&ssl_d->fields[SSLCERT_V_SERIAL].field) !=
|
|
|
|
lwc_error_ok) {
|
2013-08-12 01:11:05 +04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
ssl_d->fields[SSLCERT_V_TYPE].flags = TREE_FLAG_SHOW_NAME;
|
|
|
|
label = "TreeviewLabelType";
|
|
|
|
label = messages_get(label);
|
|
|
|
if (lwc_intern_string(label, strlen(label),
|
2017-03-02 02:47:27 +03:00
|
|
|
&ssl_d->fields[SSLCERT_V_TYPE].field) !=
|
|
|
|
lwc_error_ok) {
|
2013-08-12 01:11:05 +04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
ssl_d->fields[SSLCERT_V_VALID_UNTIL].flags = TREE_FLAG_SHOW_NAME;
|
|
|
|
label = "TreeviewLabelValidUntil";
|
|
|
|
label = messages_get(label);
|
|
|
|
if (lwc_intern_string(label, strlen(label),
|
2017-03-02 02:47:27 +03:00
|
|
|
&ssl_d->fields[SSLCERT_V_VALID_UNTIL].field) !=
|
|
|
|
lwc_error_ok) {
|
2013-08-12 01:11:05 +04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
ssl_d->fields[SSLCERT_V_VALID_FROM].flags = TREE_FLAG_SHOW_NAME;
|
|
|
|
label = "TreeviewLabelValidFrom";
|
|
|
|
label = messages_get(label);
|
|
|
|
if (lwc_intern_string(label, strlen(label),
|
2017-03-02 02:47:27 +03:00
|
|
|
&ssl_d->fields[SSLCERT_V_VALID_FROM].field) !=
|
|
|
|
lwc_error_ok) {
|
2013-08-12 01:11:05 +04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
ssl_d->fields[SSLCERT_V_VERSION].flags = TREE_FLAG_SHOW_NAME;
|
|
|
|
label = "TreeviewLabelVersion";
|
|
|
|
label = messages_get(label);
|
|
|
|
if (lwc_intern_string(label, strlen(label),
|
2017-03-02 02:47:27 +03:00
|
|
|
&ssl_d->fields[SSLCERT_V_VERSION].field) !=
|
|
|
|
lwc_error_ok) {
|
2013-08-12 01:11:05 +04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
ssl_d->fields[SSLCERT_V_ISSUER].flags = TREE_FLAG_SHOW_NAME;
|
|
|
|
label = "TreeviewLabelIssuer";
|
|
|
|
label = messages_get(label);
|
|
|
|
if (lwc_intern_string(label, strlen(label),
|
2017-03-02 02:47:27 +03:00
|
|
|
&ssl_d->fields[SSLCERT_V_ISSUER].field) !=
|
|
|
|
lwc_error_ok) {
|
2013-08-12 01:11:05 +04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
ssl_d->fields[SSLCERT_V_CERTIFICATES].flags = TREE_FLAG_DEFAULT;
|
|
|
|
label = "TreeviewLabelCertificates";
|
|
|
|
label = messages_get(label);
|
|
|
|
if (lwc_intern_string(label, strlen(label),
|
2017-03-02 02:47:27 +03:00
|
|
|
&ssl_d->fields[SSLCERT_V_CERTIFICATES].field) !=
|
|
|
|
lwc_error_ok) {
|
2013-08-12 01:11:05 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
|
|
|
|
error:
|
|
|
|
for (i = 0; i < SSLCERT_V_N_FIELDS; i++)
|
|
|
|
if (ssl_d->fields[i].field != NULL)
|
|
|
|
lwc_string_unref(ssl_d->fields[i].field);
|
|
|
|
|
|
|
|
return NSERROR_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete ssl certificate viewer entries
|
|
|
|
*
|
2017-03-02 02:47:27 +03:00
|
|
|
* \param e Entry to delete.
|
2013-08-12 01:11:05 +04:00
|
|
|
*/
|
|
|
|
static void sslcert_viewer_delete_entry(struct sslcert_entry *e)
|
|
|
|
{
|
|
|
|
sslcert_viewer_free_treeview_field_data(e);
|
|
|
|
free(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-02 02:47:27 +03:00
|
|
|
/**
|
|
|
|
* folder operation callback
|
|
|
|
*
|
|
|
|
* \param msg treeview message
|
|
|
|
* \param data message context
|
|
|
|
* \return NSERROR_OK on success
|
|
|
|
*/
|
|
|
|
static nserror
|
|
|
|
sslcert_viewer_tree_node_folder_cb(struct treeview_node_msg msg, void *data)
|
2013-08-12 01:11:05 +04:00
|
|
|
{
|
|
|
|
switch (msg.msg) {
|
|
|
|
case TREE_MSG_NODE_DELETE:
|
|
|
|
case TREE_MSG_NODE_EDIT:
|
|
|
|
case TREE_MSG_NODE_LAUNCH:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
2017-03-02 02:47:27 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* node entry callback
|
|
|
|
*
|
|
|
|
* \param msg treeview message
|
|
|
|
* \param data message context
|
|
|
|
* \return NSERROR_OK on success
|
|
|
|
*/
|
|
|
|
static nserror
|
|
|
|
sslcert_viewer_tree_node_entry_cb(struct treeview_node_msg msg, void *data)
|
2013-08-12 01:11:05 +04:00
|
|
|
{
|
|
|
|
struct sslcert_entry *e = data;
|
|
|
|
|
|
|
|
switch (msg.msg) {
|
|
|
|
case TREE_MSG_NODE_DELETE:
|
|
|
|
e->entry = NULL;
|
|
|
|
sslcert_viewer_delete_entry(e);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TREE_MSG_NODE_EDIT:
|
|
|
|
case TREE_MSG_NODE_LAUNCH:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
2017-03-02 02:47:27 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ssl certificate treeview callbacks
|
|
|
|
*/
|
2013-08-12 01:11:05 +04:00
|
|
|
struct treeview_callback_table sslv_tree_cb_t = {
|
|
|
|
.folder = sslcert_viewer_tree_node_folder_cb,
|
|
|
|
.entry = sslcert_viewer_tree_node_entry_cb
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Exported interface, documented in sslcert_viewer.h */
|
2017-03-02 02:47:27 +03:00
|
|
|
nserror
|
|
|
|
sslcert_viewer_init(struct core_window_callback_table *cw_t,
|
|
|
|
void *core_window_handle,
|
|
|
|
struct sslcert_session_data *ssl_d)
|
2013-08-12 01:11:05 +04:00
|
|
|
{
|
|
|
|
nserror err;
|
|
|
|
int cert_loop;
|
|
|
|
|
|
|
|
assert(ssl_d != NULL);
|
|
|
|
|
Treeview: Rationalise initialisation and finalisation.
Previously the expected behaviour for front ends using the correct
API for hotlist, global history, cookie manager, and ssl cert
viewer was that the front end would initialise the treeview module
on startup and finalise it on application exit.
However, this meant that the front ends had to include the core
treeview header, which they didn't otherwise need.
Since the tree module provided access to the new treeview utilities
through the old tree API, and was used by front ends with no changes
for the new treeview API, the tree layer refcounted initialisations
of treeview-based widgets, and only called the underlying treeview
init/fini functions when needed.
This change moves that refcounting into the treeview module. Now
the hotlist, global history, cookie manager, and ssl cert viewer
widgets call call treeview init/fini as part of their own
initialisation and finalisation. This means that front ends
using the correct APIs for treeview-based widgets don't need to
know anything about the underlying treeview, and the tree module
compatibility layer has had its treeview refcounting removed.
Finally, the treeview_init function took a font size parameter.
Now it does not and lit gets font size from config. We probably
want to add a new `treeview_font_size` option to nsoptions, and
have differnent defaults on different platforms. 12pt on RISC OS,
and 11pt elsewhere, most likely.
2016-08-10 20:36:41 +03:00
|
|
|
err = treeview_init();
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Building certificate viewer");
|
2013-08-12 01:11:05 +04:00
|
|
|
|
|
|
|
/* Init. certificate chain treeview entry fields */
|
|
|
|
err = sslcert_init_entry_fields(ssl_d);
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
ssl_d->tree = NULL;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the certificate treeview */
|
|
|
|
err = treeview_create(&ssl_d->tree, &sslv_tree_cb_t,
|
2017-03-02 02:47:27 +03:00
|
|
|
SSLCERT_V_N_FIELDS, ssl_d->fields,
|
|
|
|
cw_t, core_window_handle, TREEVIEW_READ_ONLY);
|
2013-08-12 01:11:05 +04:00
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
ssl_d->tree = NULL;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Build treeview nodes from certificate chain */
|
|
|
|
for (cert_loop = ssl_d->num - 1; cert_loop >= 0; cert_loop--) {
|
|
|
|
err = sslcert_viewer_create_node(ssl_d, cert_loop);
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Built certificate viewer");
|
2013-08-12 01:11:05 +04:00
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Free SSL certificate session data
|
|
|
|
*
|
2017-03-02 02:47:27 +03:00
|
|
|
* \param ssl_d SSL certificate session data
|
2013-08-12 01:11:05 +04:00
|
|
|
*/
|
|
|
|
static void sslcert_cleanup_session(struct sslcert_session_data *ssl_d)
|
|
|
|
{
|
|
|
|
assert(ssl_d != NULL);
|
|
|
|
|
2014-07-17 18:20:38 +04:00
|
|
|
if (ssl_d->url) {
|
2013-08-12 01:11:05 +04:00
|
|
|
nsurl_unref(ssl_d->url);
|
2014-07-17 18:20:38 +04:00
|
|
|
ssl_d->url = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ssl_d->certs) {
|
|
|
|
free(ssl_d->certs);
|
|
|
|
ssl_d->certs = NULL;
|
|
|
|
}
|
2013-08-12 01:11:05 +04:00
|
|
|
|
|
|
|
free(ssl_d);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Exported interface, documented in sslcert_viewer.h */
|
|
|
|
nserror sslcert_viewer_fini(struct sslcert_session_data *ssl_d)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
nserror err;
|
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Finalising ssl certificate viewer");
|
2013-08-12 01:11:05 +04:00
|
|
|
|
|
|
|
/* Destroy the treeview */
|
|
|
|
err = treeview_destroy(ssl_d->tree);
|
|
|
|
|
|
|
|
/* Free treeview entry fields */
|
|
|
|
for (i = 0; i < SSLCERT_V_N_FIELDS; i++)
|
|
|
|
if (ssl_d->fields[i].field != NULL)
|
|
|
|
lwc_string_unref(ssl_d->fields[i].field);
|
|
|
|
|
|
|
|
/* Destroy the sslcert_session_data */
|
|
|
|
sslcert_cleanup_session(ssl_d);
|
|
|
|
|
Treeview: Rationalise initialisation and finalisation.
Previously the expected behaviour for front ends using the correct
API for hotlist, global history, cookie manager, and ssl cert
viewer was that the front end would initialise the treeview module
on startup and finalise it on application exit.
However, this meant that the front ends had to include the core
treeview header, which they didn't otherwise need.
Since the tree module provided access to the new treeview utilities
through the old tree API, and was used by front ends with no changes
for the new treeview API, the tree layer refcounted initialisations
of treeview-based widgets, and only called the underlying treeview
init/fini functions when needed.
This change moves that refcounting into the treeview module. Now
the hotlist, global history, cookie manager, and ssl cert viewer
widgets call call treeview init/fini as part of their own
initialisation and finalisation. This means that front ends
using the correct APIs for treeview-based widgets don't need to
know anything about the underlying treeview, and the tree module
compatibility layer has had its treeview refcounting removed.
Finally, the treeview_init function took a font size parameter.
Now it does not and lit gets font size from config. We probably
want to add a new `treeview_font_size` option to nsoptions, and
have differnent defaults on different platforms. 12pt on RISC OS,
and 11pt elsewhere, most likely.
2016-08-10 20:36:41 +03:00
|
|
|
err = treeview_fini();
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Finalised ssl certificate viewer");
|
2013-08-12 01:11:05 +04:00
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Exported interface, documented in sslcert_viewer.h */
|
2017-03-02 02:47:27 +03:00
|
|
|
nserror
|
|
|
|
sslcert_viewer_create_session_data(unsigned long num,
|
|
|
|
nsurl *url,
|
|
|
|
llcache_query_response cb,
|
|
|
|
void *cbpw,
|
|
|
|
const struct ssl_cert_info *certs,
|
|
|
|
struct sslcert_session_data **ssl_d)
|
2013-08-12 01:11:05 +04:00
|
|
|
{
|
|
|
|
struct sslcert_session_data *data;
|
|
|
|
|
|
|
|
assert(url != NULL);
|
|
|
|
assert(certs != NULL);
|
|
|
|
|
|
|
|
data = malloc(sizeof(struct sslcert_session_data));
|
|
|
|
if (data == NULL) {
|
|
|
|
*ssl_d = NULL;
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
}
|
|
|
|
|
2014-07-17 18:20:38 +04:00
|
|
|
/* copy certificate data */
|
|
|
|
data->certs = malloc(num * sizeof(struct ssl_cert_info));
|
|
|
|
if (data->certs == NULL) {
|
|
|
|
free(data);
|
|
|
|
*ssl_d = NULL;
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
}
|
|
|
|
memcpy(data->certs, certs, num * sizeof(struct ssl_cert_info));
|
|
|
|
|
2013-08-12 01:11:05 +04:00
|
|
|
data->url = nsurl_ref(url);
|
|
|
|
data->num = num;
|
|
|
|
data->cb = cb;
|
|
|
|
data->cbpw = cbpw;
|
|
|
|
|
|
|
|
data->tree = NULL;
|
|
|
|
|
|
|
|
*ssl_d = data;
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Exported interface, documented in sslcert_viewer.h */
|
|
|
|
nserror sslcert_viewer_reject(struct sslcert_session_data *ssl_d)
|
|
|
|
{
|
|
|
|
assert(ssl_d != NULL);
|
|
|
|
|
|
|
|
ssl_d->cb(false, ssl_d->cbpw);
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Exported interface, documented in sslcert_viewer.h */
|
|
|
|
nserror sslcert_viewer_accept(struct sslcert_session_data *ssl_d)
|
|
|
|
{
|
|
|
|
assert(ssl_d != NULL);
|
|
|
|
|
|
|
|
urldb_set_cert_permissions(ssl_d->url, true);
|
|
|
|
|
|
|
|
ssl_d->cb(true, ssl_d->cbpw);
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Exported interface, documented in sslcert_viewer.h */
|
2017-03-02 02:47:27 +03:00
|
|
|
void
|
|
|
|
sslcert_viewer_redraw(struct sslcert_session_data *ssl_d,
|
|
|
|
int x, int y,
|
|
|
|
struct rect *clip,
|
|
|
|
const struct redraw_context *ctx)
|
2013-08-12 01:11:05 +04:00
|
|
|
{
|
2014-07-17 03:18:44 +04:00
|
|
|
assert(ssl_d != NULL &&
|
|
|
|
"sslcert_viewer_redraw() given bad session data");
|
|
|
|
|
2013-08-12 01:11:05 +04:00
|
|
|
treeview_redraw(ssl_d->tree, x, y, clip, ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Exported interface, documented in sslcert_viewer.h */
|
2017-03-02 02:47:27 +03:00
|
|
|
void
|
|
|
|
sslcert_viewer_mouse_action(struct sslcert_session_data *ssl_d,
|
|
|
|
browser_mouse_state mouse,
|
|
|
|
int x, int y)
|
2013-08-12 01:11:05 +04:00
|
|
|
{
|
|
|
|
treeview_mouse_action(ssl_d->tree, mouse, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Exported interface, documented in sslcert_viewer.h */
|
2016-07-31 13:38:03 +03:00
|
|
|
bool sslcert_viewer_keypress(struct sslcert_session_data *ssl_d, uint32_t key)
|
2013-08-12 01:11:05 +04:00
|
|
|
{
|
2016-07-31 13:38:03 +03:00
|
|
|
return treeview_keypress(ssl_d->tree, key);
|
2013-08-12 01:11:05 +04:00
|
|
|
}
|