mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Parse TLS cert subject
This commit is contained in:
parent
1eab57bd13
commit
40ce5cb0e0
@ -650,9 +650,42 @@ sv_ev_certfail(const char * const errormsg, const char * const certname, const c
|
|||||||
}
|
}
|
||||||
prefs_free_trusted_certs(trusted);
|
prefs_free_trusted_certs(trusted);
|
||||||
|
|
||||||
|
char *domain = NULL;
|
||||||
|
char *org = NULL;
|
||||||
|
char *email = NULL;
|
||||||
|
gchar** fields = g_strsplit(certname, "/", 0);
|
||||||
|
int i = 0;
|
||||||
|
for (i = 0; i < g_strv_length(fields); i++) {
|
||||||
|
gchar** keyval = g_strsplit(fields[i], "=", 2);
|
||||||
|
if (g_strv_length(keyval) == 2) {
|
||||||
|
if (g_strcmp0(keyval[0], "CN") == 0) {
|
||||||
|
domain = strdup(keyval[1]);
|
||||||
|
}
|
||||||
|
if (g_strcmp0(keyval[0], "O") == 0) {
|
||||||
|
org = strdup(keyval[1]);
|
||||||
|
}
|
||||||
|
if (g_strcmp0(keyval[0], "emailAddress") == 0) {
|
||||||
|
email = strdup(keyval[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_strfreev(keyval);
|
||||||
|
}
|
||||||
|
g_strfreev(fields);
|
||||||
|
|
||||||
cons_show("");
|
cons_show("");
|
||||||
cons_show_error("TLS certificate verification failed: %s", errormsg);
|
cons_show_error("TLS certificate verification failed: %s", errormsg);
|
||||||
cons_show(" Subject : %s", certname);
|
if (domain) {
|
||||||
|
cons_show(" Domain : %s", domain);
|
||||||
|
free(domain);
|
||||||
|
}
|
||||||
|
if (org) {
|
||||||
|
cons_show(" Organisation : %s", org);
|
||||||
|
free(org);
|
||||||
|
}
|
||||||
|
if (email) {
|
||||||
|
cons_show(" Email : %s", email);
|
||||||
|
free(email);
|
||||||
|
}
|
||||||
cons_show(" Fingerprint : %s", certfp);
|
cons_show(" Fingerprint : %s", certfp);
|
||||||
cons_show(" Start : %s", notbefore);
|
cons_show(" Start : %s", notbefore);
|
||||||
cons_show(" End : %s", notafter);
|
cons_show(" End : %s", notafter);
|
||||||
|
Loading…
Reference in New Issue
Block a user