27#include <nsutils/base64.h>
133#define MIN_CERT_LEN 64
144 (strncmp(str,
"cert=", 5) == 0)) {
146 nsures = nsu_base64_decode_alloc_url(
147 (
const uint8_t *)str + 5,
151 if (nsures == NSUERROR_OK) {
154 }
else if ((len > 8) &&
155 (strncmp(str,
"certerr=", 8) == 0)) {
157 if (chain->
depth > 0) {
158 chain->
certs[chain->
depth - 1].
err = strtoul(str + 8, NULL, 10);
194 for (kvlen = 0, kvstart = 0; kvstart < querylen; kvstart += kvlen) {
197 while (((kvstart + kvlen) < querylen) &&
198 (querystr[kvstart + kvlen] !=
'&')) {
210 if (chain->
depth > 0) {
244 urlstr = malloc(allocsize);
245 if (urlstr == NULL) {
249 urlstrlen = snprintf((
char *)urlstr, allocsize,
"about:certificate");
253 size_t output_length;
255 written = snprintf((
char *)urlstr + urlstrlen,
256 allocsize - urlstrlen,
262 if ((
size_t)written >= allocsize - urlstrlen) {
267 urlstrlen += (size_t)written;
269 output_length = allocsize - urlstrlen;
270 nsures = nsu_base64_encode_url(
273 (uint8_t *)urlstr + urlstrlen,
275 if (nsures != NSUERROR_OK) {
279 urlstrlen += output_length;
282 written = snprintf((
char *)urlstr + urlstrlen,
283 allocsize - urlstrlen,
290 if ((
size_t)written >= allocsize - urlstrlen) {
295 urlstrlen += (size_t)written;
300 urlstr[urlstrlen] = 0;
nserror
Enumeration of error codes.
@ NSERROR_NEED_DATA
More data needed.
@ NSERROR_UNKNOWN
Unknown error - DO NOT USE.
@ NSERROR_INVALID
Invalid data.
@ NSERROR_NOMEM
Memory exhaustion.
NetSurf URL handling (interface).
nserror nsurl_create(const char *const url_s, nsurl **url)
Create a NetSurf URL object from a URL string.
nserror nsurl_get(const nsurl *url, nsurl_component parts, char **url_s, size_t *url_l)
Get URL (section) as a string, from a NetSurf URL object.
struct nsurl nsurl
NetSurf URL object.
nserror cert_chain_from_query(struct nsurl *url, struct cert_chain **chain_out)
create a certificate chain from a fetch query string
nserror cert_chain_alloc(size_t depth, struct cert_chain **chain_out)
create new certificate chain
nserror cert_chain_dup_into(const struct cert_chain *src, struct cert_chain *dst)
duplicate a certificate chain into an existing chain
static nserror process_query_section(const char *str, size_t len, struct cert_chain *chain)
process a part of a query extracting the certificate of an error code
nserror cert_chain_dup(const struct cert_chain *src, struct cert_chain **dst_out)
duplicate a certificate chain
nserror cert_chain_free(struct cert_chain *chain)
free a certificate chain
size_t cert_chain_size(const struct cert_chain *chain)
total number of data bytes in a chain
nserror cert_chain_to_query(struct cert_chain *chain, struct nsurl **url_out)
create a fetch query string from a certificate chain
SSL related types and values.
@ SSL_CERT_ERR_OK
Nothing wrong with this certificate.
Interface to utility string handling.
struct cert_chain::@57 certs[MAX_CERT_DEPTH]
size_t depth
the number of certificates in the chain
uint8_t * der
data in Distinguished Encoding Rules (DER) format
size_t der_length
DER length.
ssl_cert_err err
Whatever is wrong with this certificate.