commit - b658d4915d7f52e5f39fa819650af807c0bd88f3
commit + 71bc16365736f1cc3212d46f3947806c1e33867b
blob - 8fe836bafd79157603410675781bc6f214e85bb5
blob + 34eb02ee9a44f1132f85dd5d6657d1ab5381c1be
--- certs.c
+++ certs.c
}
const char *
-cert_for(struct iri *iri)
+cert_for(struct iri *iri, int *temporary)
{
struct ccert *c;
- if ((c = find_cert_for(&temp_store, iri, NULL)) != NULL)
+ *temporary = 0;
+
+ if ((c = find_cert_for(&temp_store, iri, NULL)) != NULL) {
+ *temporary = 1;
return (c->cert);
+ }
if ((c = find_cert_for(&cert_store, iri, NULL)) != NULL)
return (c->cert);
return (NULL);
blob - f889567e82635d187d12dcc9b540471639eb0ddc
blob + 04d0246480ec6f44be8df1d20dcf2aed524374ae
--- certs.h
+++ certs.h
int certs_init(const char *);
const char *ccert(const char *);
-const char *cert_for(struct iri *);
+const char *cert_for(struct iri *, int *);
int cert_save_for(const char *, struct iri *, int);
int cert_delete_for(const char *, struct iri *, int);
int cert_open(const char *);
blob - 9dc9d7180bcae9f7a0f61ddc71d24858e9b1643c
blob + 16927d7f8b2759c895120017509f67f0dd66d505
--- cmd.c
+++ cmd.c
static void
unload_certificate_cb(int r, struct tab *tab)
{
+ message("Won't use %s for this site.", tab->client_cert);
cert_delete_for(tab->client_cert, &tab->iri, r);
}
void
cmd_unload_certificate(struct buffer *buffer)
{
+ struct tab *tab = current_tab;
+
GUARD_RECURSIVE_MINIBUFFER();
- if (current_tab->client_cert == NULL) {
+ if (tab->client_cert == NULL) {
message("No client certificate in use!");
return;
}
- /* Sucks that we ask this even when the cert is already temporary */
+ if (tab->client_cert_temp) {
+ message("Won't use %s for this site.", tab->client_cert);
+ cert_delete_for(tab->client_cert, &tab->iri, 0);
+ return;
+ }
+
yornp("Unload only for the current session?", unload_certificate_cb,
current_tab);
}
blob - 555f69ecb0f9371d00a0c1cc99c4a50c56780bcc
blob + b4c2cf15b1ed9eccbc3f0e842e26b165ac397ed9
--- telescope.c
+++ telescope.c
static void load_via_proxy(struct tab *, const char *,
struct proxy *);
static void make_request(struct tab *, struct get_req *, int,
- const char *, int);
+ const char *);
static void do_load_url(struct tab *, const char *, const char *, int);
static pid_t start_child(enum telescope_process, const char *, int);
static void send_url(const char *);
strlcat(req.req, "\r\n", sizeof(req.req));
parser_init(tab, textplain_initparser);
- make_request(tab, &req, PROTO_FINGER, NULL, 0);
+ make_request(tab, &req, PROTO_FINGER, NULL);
}
static void
load_gemini_url(struct tab *tab, const char *url)
{
struct get_req req;
- int use_cert = 0;
-
- if ((tab->client_cert = cert_for(&tab->iri)) != NULL)
- use_cert = 1;
memset(&req, 0, sizeof(req));
strlcpy(req.host, tab->iri.iri_host, sizeof(req.host));
strlcpy(req.port, tab->iri.iri_portstr, sizeof(req.port));
- make_request(tab, &req, PROTO_GEMINI, hist_cur(tab->hist), use_cert);
+ make_request(tab, &req, PROTO_GEMINI, hist_cur(tab->hist));
}
static inline const char *
}
strlcat(req.req, "\r\n", sizeof(req.req));
- make_request(tab, &req, PROTO_GOPHER, NULL, 0);
+ make_request(tab, &req, PROTO_GOPHER, NULL);
}
static void
tab->proxy = p;
- make_request(tab, &req, p->proto, hist_cur(tab->hist), 0);
+ make_request(tab, &req, p->proto, hist_cur(tab->hist));
}
static void
-make_request(struct tab *tab, struct get_req *req, int proto, const char *r,
- int use_cert)
+make_request(struct tab *tab, struct get_req *req, int proto, const char *r)
{
- int fd = -1;
+ int use_cert = 0, fd = -1;
+
+ if (proto == PROTO_GEMINI) {
+ tab->client_cert = cert_for(&tab->iri, &tab->client_cert_temp);
+ use_cert = (tab->client_cert != NULL);
+ }
stop_tab(tab);
tab->id = tab_new_id();
erase_buffer(&tab->buffer);
parser_init(tab, gophermap_initparser);
- make_request(tab, &req, PROTO_GOPHER, NULL, 0);
+ make_request(tab, &req, PROTO_GOPHER, NULL);
}
void
blob - 69895df6b55abbe22eee103fa8d64bb8d882ea42
blob + cf1297fdfadd033ea352e0e23b27b1d18d0c8292
--- telescope.h
+++ telescope.h
char *cert;
enum trust_state trust;
const char *client_cert;
+ int client_cert_temp;
struct proxy *proxy;
struct iri iri;
struct hist *hist;