NetSurf
Data Structures | Typedefs | Enumerations | Functions | Variables
sslcert_viewer.c File Reference

SSL Certificate verification UI implementation. More...

#include <assert.h>
#include <stdlib.h>
#include "content/fetch.h"
#include "content/urldb.h"
#include "content/hlcache.h"
#include "desktop/sslcert_viewer.h"
#include "desktop/treeview.h"
#include "utils/messages.h"
#include "utils/log.h"
#include "utils/utils.h"
Include dependency graph for sslcert_viewer.c:

Go to the source code of this file.

Data Structures

struct  sslcert_session_data
 ssl certificate verification context. More...
 
struct  sslcert_entry
 ssl certificate tree entry More...
 

Typedefs

typedef nserror(* response_cb) (bool proceed, void *pw)
 

Enumerations

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
}
 ssl certificate viewer data fields More...
 

Functions

static void sslcert_viewer_free_treeview_field_data (struct sslcert_entry *e)
 Free a ssl certificate viewer entry's treeview field data. More...
 
static nserror sslcert_viewer_field_builder (enum sslcert_viewer_field field, struct treeview_field_data *data, const char *value, struct sslcert_session_data *ssl_d)
 Build a sslcert viewer treeview field from given text. More...
 
static nserror sslcert_viewer_set_treeview_field_data (struct sslcert_entry *e, const struct ssl_cert_info *cert, struct sslcert_session_data *ssl_d)
 Set a sslcert viewer entry's data from the certificate. More...
 
static nserror sslcert_viewer_create_node (struct sslcert_session_data *ssl_d, int n)
 Create a treeview node for a certificate. More...
 
static nserror sslcert_init_entry_fields (struct sslcert_session_data *ssl_d)
 Initialise the treeview entry fields. More...
 
static void sslcert_viewer_delete_entry (struct sslcert_entry *e)
 Delete ssl certificate viewer entries. More...
 
static nserror sslcert_viewer_tree_node_folder_cb (struct treeview_node_msg msg, void *data)
 folder operation callback More...
 
static nserror sslcert_viewer_tree_node_entry_cb (struct treeview_node_msg msg, void *data)
 node entry callback More...
 
nserror sslcert_viewer_init (struct core_window_callback_table *cw_t, void *core_window_handle, struct sslcert_session_data *ssl_d)
 Initialise a ssl certificate viewer from session data. More...
 
static void sslcert_cleanup_session (struct sslcert_session_data *ssl_d)
 Free SSL certificate session data. More...
 
nserror sslcert_viewer_fini (struct sslcert_session_data *ssl_d)
 Finalise a ssl certificate viewer. More...
 
nserror sslcert_viewer_create_session_data (unsigned long num, struct nsurl *url, nserror(*cb)(bool proceed, void *pw), void *cbpw, const struct ssl_cert_info *certs, struct sslcert_session_data **ssl_d)
 Create ssl certificate viewer session data. More...
 
nserror sslcert_viewer_reject (struct sslcert_session_data *ssl_d)
 Reject a certificate chain. More...
 
nserror sslcert_viewer_accept (struct sslcert_session_data *ssl_d)
 Accept a certificate chain. More...
 
void sslcert_viewer_redraw (struct sslcert_session_data *ssl_d, int x, int y, struct rect *clip, const struct redraw_context *ctx)
 Redraw the ssl certificate viewer. More...
 
void sslcert_viewer_mouse_action (struct sslcert_session_data *ssl_d, browser_mouse_state mouse, int x, int y)
 Handles all kinds of mouse action. More...
 
bool sslcert_viewer_keypress (struct sslcert_session_data *ssl_d, uint32_t key)
 Key press handling. More...
 

Variables

struct treeview_callback_table sslv_tree_cb_t
 ssl certificate treeview callbacks More...
 

Detailed Description

SSL Certificate verification UI implementation.

Definition in file sslcert_viewer.c.

Typedef Documentation

◆ response_cb

typedef nserror(* response_cb) (bool proceed, void *pw)

Definition at line 52 of file sslcert_viewer.c.

Enumeration Type Documentation

◆ sslcert_viewer_field

ssl certificate viewer data fields

Enumerator
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 

Definition at line 40 of file sslcert_viewer.c.

Function Documentation

◆ sslcert_cleanup_session()

static void sslcert_cleanup_session ( struct sslcert_session_data ssl_d)
static

Free SSL certificate session data.

Parameters
ssl_dSSL certificate session data

Definition at line 429 of file sslcert_viewer.c.

References sslcert_session_data::certs, nsurl_unref(), and sslcert_session_data::url.

Referenced by sslcert_viewer_fini().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sslcert_init_entry_fields()

static nserror sslcert_init_entry_fields ( struct sslcert_session_data ssl_d)
static

Initialise the treeview entry fields.

Parameters
ssl_dSSL certificate session data
Returns
NSERROR_OK on success otherwise error code.

Definition at line 216 of file sslcert_viewer.c.

References treeview_field_desc::field, sslcert_session_data::fields, treeview_field_desc::flags, messages_get(), NSERROR_OK, NSERROR_UNKNOWN, SSLCERT_V_CERTIFICATES, SSLCERT_V_ISSUER, SSLCERT_V_N_FIELDS, SSLCERT_V_SERIAL, SSLCERT_V_SUBJECT, SSLCERT_V_TYPE, SSLCERT_V_VALID_FROM, SSLCERT_V_VALID_UNTIL, SSLCERT_V_VERSION, TREE_FLAG_DEFAULT, and TREE_FLAG_SHOW_NAME.

Referenced by sslcert_viewer_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sslcert_viewer_accept()

nserror sslcert_viewer_accept ( struct sslcert_session_data ssl_d)

Accept a certificate chain.

Parameters
ssl_dSSL certificate session data
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 530 of file sslcert_viewer.c.

References sslcert_session_data::cb, sslcert_session_data::cbpw, NSERROR_OK, sslcert_session_data::url, and urldb_set_cert_permissions().

Referenced by ami_crtvrfy_accept(), handle_event(), nsgtk_crtvrfy_accept(), nsw32_window_ssl_cert_command(), and ro_gui_cert_accept().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sslcert_viewer_create_node()

static nserror sslcert_viewer_create_node ( struct sslcert_session_data ssl_d,
int  n 
)
static

Create a treeview node for a certificate.

Parameters
ssl_dSSL certificate session data
nNumber of SSL certificate in chain, to make node for
Returns
NSERROR_OK on success otherwise error code.

Definition at line 178 of file sslcert_viewer.c.

References sslcert_session_data::certs, sslcert_entry::data, sslcert_entry::entry, ssl_cert_info::err, NSERROR_NOMEM, NSERROR_OK, sslcert_viewer_free_treeview_field_data(), sslcert_viewer_set_treeview_field_data(), sslcert_session_data::tree, TREE_OPTION_NONE, TREE_REL_FIRST_CHILD, and treeview_create_node_entry().

Referenced by sslcert_viewer_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sslcert_viewer_create_session_data()

nserror sslcert_viewer_create_session_data ( unsigned long  num,
struct nsurl url,
nserror(*)(bool proceed, void *pw)  cb,
void *  cbpw,
const struct ssl_cert_info certs,
struct sslcert_session_data **  ssl_d 
)

Create ssl certificate viewer session data.

Parameters
numThe number of certificates in the chain
urlAddress of the page we're inspecting certificates of
cbLow level cache callback
cbpwLow level cache private data
certsThe SSL certificates
ssl_dUpdated to SSL certificate session data
Returns
NSERROR_OK on success, appropriate error otherwise

Pass the session data to sslcert_viewer_init. sslcert_viewer_fini destroys the session data.

Definition at line 479 of file sslcert_viewer.c.

References sslcert_session_data::cb, sslcert_session_data::cbpw, sslcert_session_data::certs, NSERROR_NOMEM, NSERROR_OK, nsurl_ref(), sslcert_session_data::num, sslcert_session_data::tree, and sslcert_session_data::url.

Referenced by ami_cert_verify(), gtk_cert_verify(), gui_cert_verify(), and nsw32_cert_verify().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sslcert_viewer_delete_entry()

static void sslcert_viewer_delete_entry ( struct sslcert_entry e)
static

Delete ssl certificate viewer entries.

Parameters
eEntry to delete.

Definition at line 312 of file sslcert_viewer.c.

References sslcert_viewer_free_treeview_field_data().

Referenced by sslcert_viewer_tree_node_entry_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sslcert_viewer_field_builder()

static nserror sslcert_viewer_field_builder ( enum sslcert_viewer_field  field,
struct treeview_field_data data,
const char *  value,
struct sslcert_session_data ssl_d 
)
inlinestatic

Build a sslcert viewer treeview field from given text.

Parameters
fieldSSL certificate treeview field to build
dataSSL certificate entry field data to set
valueText to set in field, ownership yielded
ssl_dSSL certificate session data
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 100 of file sslcert_viewer.c.

References treeview_field_desc::field, treeview_field_data::field, sslcert_session_data::fields, NSERROR_OK, treeview_field_data::value, and treeview_field_data::value_len.

Referenced by sslcert_viewer_set_treeview_field_data().

Here is the caller graph for this function:

◆ sslcert_viewer_fini()

nserror sslcert_viewer_fini ( struct sslcert_session_data ssl_d)

Finalise a ssl certificate viewer.

This destroys the certificate treeview and the certificate viewer module's session data.

Parameters
ssl_dSSL certificate session data
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 448 of file sslcert_viewer.c.

References treeview_field_desc::field, sslcert_session_data::fields, NSERROR_OK, NSLOG, sslcert_cleanup_session(), SSLCERT_V_N_FIELDS, sslcert_session_data::tree, treeview_destroy(), and treeview_fini().

Referenced by ami_crtvrfy_destroy(), atari_sslcert_viewer_finish(), nsgtk_crtvrfy_destroy(), nsw32_crtvrfy_destroy(), and ro_gui_cert_release_window().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sslcert_viewer_free_treeview_field_data()

static void sslcert_viewer_free_treeview_field_data ( struct sslcert_entry e)
static

Free a ssl certificate viewer entry's treeview field data.

Parameters
eEntry to free data from

Definition at line 85 of file sslcert_viewer.c.

Referenced by sslcert_viewer_create_node(), and sslcert_viewer_delete_entry().

Here is the caller graph for this function:

◆ sslcert_viewer_init()

nserror sslcert_viewer_init ( struct core_window_callback_table cw_t,
void *  core_window_handle,
struct sslcert_session_data ssl_d 
)

Initialise a ssl certificate viewer from session data.

This iterates through the certificates, building a treeview.

Parameters
cw_tCallback table for cert viewer's core_window
core_window_handleThe core_window in which the cert viewer is shown
ssl_dSSL certificate session data
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 378 of file sslcert_viewer.c.

References sslcert_session_data::fields, NSERROR_OK, NSLOG, sslcert_session_data::num, sslcert_init_entry_fields(), SSLCERT_V_N_FIELDS, sslcert_viewer_create_node(), sslcert_session_data::tree, treeview_create(), treeview_init(), and TREEVIEW_READ_ONLY.

Referenced by ami_cert_verify(), atari_sslcert_viewer_init_phase2(), gtk_cert_verify(), gui_cert_verify(), and nsw32_cert_verify().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sslcert_viewer_keypress()

bool sslcert_viewer_keypress ( struct sslcert_session_data ssl_d,
uint32_t  key 
)

Key press handling.

Parameters
ssl_dSSL certificate session data
keyThe ucs4 character codepoint
Returns
true if the keypress is dealt with, false otherwise.

Definition at line 567 of file sslcert_viewer.c.

References sslcert_session_data::tree, and treeview_keypress().

Referenced by ami_crtvrfy_key(), atari_sslcert_viewer_keypress(), cert_key(), nsgtk_crtvrfy_key(), and nsw32_sslcert_viewer_key().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sslcert_viewer_mouse_action()

void sslcert_viewer_mouse_action ( struct sslcert_session_data ssl_d,
browser_mouse_state  mouse,
int  x,
int  y 
)

Handles all kinds of mouse action.

Parameters
ssl_dSSL certificate session data
mouseThe current mouse state
xX coordinate
yY coordinate

Definition at line 558 of file sslcert_viewer.c.

References sslcert_session_data::tree, and treeview_mouse_action().

Referenced by ami_crtvrfy_mouse(), atari_sslcert_viewer_mouse_action(), cert_mouse(), nsgtk_crtvrfy_mouse(), and nsw32_sslcert_viewer_mouse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sslcert_viewer_redraw()

void sslcert_viewer_redraw ( struct sslcert_session_data ssl_d,
int  x,
int  y,
struct rect clip,
const struct redraw_context ctx 
)

Redraw the ssl certificate viewer.

Parameters
ssl_dSSL certificate session data
xX coordinate to render treeview at
yY coordinate to render treeview at
clipCurrent clip rectangle (wrt tree origin)
ctxCurrent redraw context

Definition at line 544 of file sslcert_viewer.c.

References sslcert_session_data::tree, and treeview_redraw().

Referenced by ami_crtvrfy_draw(), atari_sslcert_viewer_draw(), cert_draw(), nsgtk_crtvrfy_draw(), and nsw32_sslcert_viewer_draw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sslcert_viewer_reject()

nserror sslcert_viewer_reject ( struct sslcert_session_data ssl_d)

Reject a certificate chain.

Parameters
ssl_dSSL certificate session data
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 519 of file sslcert_viewer.c.

References sslcert_session_data::cb, sslcert_session_data::cbpw, and NSERROR_OK.

Referenced by ami_crtvrfy_reject(), handle_event(), nsgtk_crtvrfy_reject(), nsw32_window_ssl_cert_command(), nsw32_window_ssl_cert_event_callback(), and ro_gui_cert_reject().

Here is the caller graph for this function:

◆ sslcert_viewer_set_treeview_field_data()

static nserror sslcert_viewer_set_treeview_field_data ( struct sslcert_entry e,
const struct ssl_cert_info cert,
struct sslcert_session_data ssl_d 
)
static

Set a sslcert viewer entry's data from the certificate.

Parameters
eEntry to set up
certData associated with entry's certificate
ssl_dSSL certificate session data
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 122 of file sslcert_viewer.c.

References ssl_cert_info::cert_type, sslcert_entry::data, ssl_cert_info::issuer, ssl_cert_info::not_after, ssl_cert_info::not_before, NSERROR_OK, ssl_cert_info::serialnum, SSLCERT_V_ISSUER, SSLCERT_V_SERIAL, SSLCERT_V_SUBJECT, SSLCERT_V_TYPE, SSLCERT_V_VALID_FROM, SSLCERT_V_VALID_UNTIL, SSLCERT_V_VERSION, sslcert_viewer_field_builder(), ssl_cert_info::subject, sslcert_entry::type, ssl_cert_info::version, and sslcert_entry::version.

Referenced by sslcert_viewer_create_node().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sslcert_viewer_tree_node_entry_cb()

static nserror sslcert_viewer_tree_node_entry_cb ( struct treeview_node_msg  msg,
void *  data 
)
static

node entry callback

Parameters
msgtreeview message
datamessage context
Returns
NSERROR_OK on success

Definition at line 348 of file sslcert_viewer.c.

References sslcert_entry::data, sslcert_entry::entry, treeview_node_msg::msg, NSERROR_OK, sslcert_viewer_delete_entry(), TREE_MSG_NODE_DELETE, TREE_MSG_NODE_EDIT, and TREE_MSG_NODE_LAUNCH.

Here is the call graph for this function:

◆ sslcert_viewer_tree_node_folder_cb()

static nserror sslcert_viewer_tree_node_folder_cb ( struct treeview_node_msg  msg,
void *  data 
)
static

folder operation callback

Parameters
msgtreeview message
datamessage context
Returns
NSERROR_OK on success

Definition at line 327 of file sslcert_viewer.c.

References treeview_node_msg::msg, NSERROR_OK, TREE_MSG_NODE_DELETE, TREE_MSG_NODE_EDIT, and TREE_MSG_NODE_LAUNCH.

Variable Documentation

◆ sslv_tree_cb_t

struct treeview_callback_table sslv_tree_cb_t
Initial value:
= {
}
static nserror sslcert_viewer_tree_node_entry_cb(struct treeview_node_msg msg, void *data)
node entry callback
static nserror sslcert_viewer_tree_node_folder_cb(struct treeview_node_msg msg, void *data)
folder operation callback

ssl certificate treeview callbacks

Definition at line 370 of file sslcert_viewer.c.