about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-11-09 20:57:26 +0000
committerJames Booth <boothj5@gmail.com>2015-11-09 20:57:26 +0000
commit4cbfb888141cf060608f213499672e0b2c56f331 (patch)
tree88e9c4866369e5212996e5c6f7b78617902e02f9 /src
parentb3737b225f35a04b34076ff1e581d44c959bd59e (diff)
downloadprofani-tty-4cbfb888141cf060608f213499672e0b2c56f331.tar.gz
Store current TLS certificate fingerpint in memory for reconnect
Diffstat (limited to 'src')
-rw-r--r--src/command/commands.c1
-rw-r--r--src/config/tlscerts.c32
-rw-r--r--src/config/tlscerts.h6
-rw-r--r--src/event/server_events.c8
4 files changed, 47 insertions, 0 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index 0331d691..cf7290ad 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -831,6 +831,7 @@ cmd_disconnect(ProfWin *window, const char *const command, gchar **args)
         roster_clear();
         muc_invites_clear();
         chat_sessions_clear();
+        tlscerts_clear_current();
         ui_disconnected();
 #ifdef HAVE_LIBGPGME
         p_gpg_on_disconnect();
diff --git a/src/config/tlscerts.c b/src/config/tlscerts.c
index 17c32cb5..299b98cf 100644
--- a/src/config/tlscerts.c
+++ b/src/config/tlscerts.c
@@ -51,6 +51,8 @@ static void _save_tlscerts(void);
 
 static Autocomplete certs_ac;
 
+static char *current_fp;
+
 void
 tlscerts_init(void)
 {
@@ -73,6 +75,32 @@ tlscerts_init(void)
         autocomplete_add(certs_ac, groups[i]);
     }
     g_strfreev(groups);
+
+    current_fp = NULL;
+}
+
+void
+tlscerts_set_current(const char *const fp)
+{
+    if (current_fp) {
+        free(current_fp);
+    }
+    current_fp = strdup(fp);
+}
+
+char*
+tlscerts_get_current(void)
+{
+    return current_fp;
+}
+
+void
+tlscerts_clear_current(void)
+{
+    if (current_fp) {
+        free(current_fp);
+        current_fp = NULL;
+    }
 }
 
 gboolean
@@ -223,6 +251,10 @@ tlscerts_close(void)
 {
     g_key_file_free(tlscerts);
     tlscerts = NULL;
+
+    free(current_fp);
+    current_fp = NULL;
+
     autocomplete_free(certs_ac);
 }
 
diff --git a/src/config/tlscerts.h b/src/config/tlscerts.h
index dfb200b7..c3b273e7 100644
--- a/src/config/tlscerts.h
+++ b/src/config/tlscerts.h
@@ -50,6 +50,12 @@ TLSCertificate* tlscerts_new(const char *const fingerprint, const char *const do
     const char *const organisation, const char *const email,
     const char *const notbefore, const char *const notafter);
 
+void tlscerts_set_current(const char *const fp);
+
+char* tlscerts_get_current(void);
+
+void tlscerts_clear_current(void);
+
 gboolean tlscerts_exists(const char *const fingerprint);
 
 void tlscerts_add(TLSCertificate *cert);
diff --git a/src/event/server_events.c b/src/event/server_events.c
index 3622b327..032c8d16 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -718,10 +718,17 @@ int
 sv_ev_certfail(const char *const errormsg, const char *const certname, const char *const certfp,
     const char *const notbefore, const char *const notafter)
 {
+    // check profanity trusted certs
     if (tlscerts_exists(certfp)) {
         return 1;
     }
 
+    // check current cert
+    char *current_fp = tlscerts_get_current();
+    if (current_fp && g_strcmp0(current_fp, certfp) == 0) {
+        return 1;
+    }
+
     char *domain = NULL;
     char *org = NULL;
     char *email = NULL;
@@ -780,6 +787,7 @@ sv_ev_certfail(const char *const errormsg, const char *const certname, const cha
     }
 
     if (g_strcmp0(cmd, "/tls allow") == 0) {
+        tlscerts_set_current(certfp);
         free(cmd);
         free(domain);
         free(org);
='n69' href='#n69'>69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132


                                             


                                                                   




























































































                                                                                       
                                                                                                       

            
                                                                                                       
     
                                                                                              






                          
                                                                  

            
                                                                  
     
                                                         







                                                          
                                                                       

                          
                                     

                                 
!	Make LYNX hypertext browser under VMS
!       =====================================
!
!	NOTE:  Use [.SRC.CHRTRANS]BUILD-CHRTRANS.COM to create the
!	       chrtrans header files before using this descrip.mms.
!
! History:
!  01/01/93 creation at KU (Lou montulli@ukanaix.cc.ukans.edu). 
!  04/12/93 (seb@lns61.tn.cornell.edu)
!            modified to support either UCX or MULTINET
!  12/13/93 (macrides@sci.wfeb.edu)
!	     Added conditional compilations for VAXC vs. DECC
!	     (dependencies not yet specified; this is just a
!	      "starter", should anyone want to do it well).
!  10/26/94 (dyson@IowaSP.Physics.UIowa.EDU) RLD
!            Updated for AXP/VMS v6.1 and VAX/VMS v5.5-1
!  12/07/94 (macrides@sci.wfeb.edu)
!	     Updated for DECC/VAX, VAXC/VAX and DECC/AXP
!  02/17/95 (macrides@sci.wfeb.edu)
!	     Updated for v2.3-FM
!  03/23/95 (macrides@sci.wfeb.edu)
!	     Replaced references to v2.3.8 or v2.3.9 with v2.3-FM to
!	     avoid any confusion with official releases at UKans.
!  07/29/95 (macrides@sci.wfeb.edu)
!	     Added support for GNUC.
!
! Instructions:
!	Use the correct command line for your TCP/IP implementation:
!
!	$ MMS /Macro = (MULTINET=1)		for VAXC - MultiNet
!	$ MMS /Macro = (WIN_TCP=1)		for VAXC - Wollongong TCP/IP
!	$ MMS /Macro = (UCX=1)			for VAXC - UCX
!	$ MMS /Macro = (CMU_TCP=1)		for VAXC - OpenCMU TCP/IP
!	$ MMS /Macro = (SOCKETSHR_TCP=1)	for VAXC - SOCKETSHR/NETLIB
!	$ MMS /Macro = (TCPWARE=1)		for VAXC - TCPWare TCP/IP
!	$ MMS /Macro = (DECNET=1)		for VAXC - socket emulation over DECnet
!
!	$ MMS /Macro = (MULTINET=1, DEC_C=1)	for DECC - MultiNet
!	$ MMS /Macro = (WIN_TCP=1, DEC_C=1)	for DECC - Wollongong TCP/IP
!	$ MMS /Macro = (UCX=1, DEC_C=1)		for DECC - UCX
!	$ MMS /Macro = (CMU_TCP=1, DEC_C=1)	for DECC - OpenCMU TCP/IP
!	$ MMS /Macro = (SOCKETSHR_TCP=1,DEC_C=1) for DECC - SOCKETSHR/NETLIB
!	$ MMS /Macro = (TCPWARE=1, DEC_C=1)	for DECC - TCPWare TCP/IP
!	$ MMS /Macro = (DECNET=1, DEC_C=1)	for DECC - socket emulation over DECnet
!
!	$ MMS /Macro = (MULTINET=1, GNU_C=1)	for GNUC - MultiNet
!	$ MMS /Macro = (WIN_TCP=1, GNU_C=1)	for GNUC - Wollongong TCP/IP
!	$ MMS /Macro = (UCX=1, GNU_C=1)		for GNUC - UCX
!	$ MMS /Macro = (CMU_TCP=1, GNU_C=1)	for GNUC - OpenCMU TCP/IP
!	$ MMS /Macro = (SOCKETSHR_TCP=1,GNU_C=1) for GNUC - SOCKETSHR/NETLIB
!	$ MMS /Macro = (TCPWARE=1, GNU_C=1)	for GNUC - TCPWare TCP/IP
!	$ MMS /Macro = (DECNET=1, GNU_C=1)	for GNUC - socket emulation over DECnet

.ifdef MULTINET
TCPM = MULTINET
.endif

.ifdef WIN_TCP
TCPM = WIN_TCP
.endif

.ifdef UCX
TCPM = UCX
.endif

.ifdef CMU_TCP
TCPM = CMU_TCP
.endif

.ifdef SOCKETSHR_TCP
TCPM = SOCKETSHR_TCP
.endif

.ifdef TCPWARE
TCPM = TCPWARE
.endif

.ifdef DECNET
TCPM = DECNET
.endif

.ifdef TCPM
.else
TCPM = MULTINET	!Default to MultiNet
.endif

.ifdef GNU_C
CC = gcc
.endif

lynx :	lynx.exe
	! Finished Building LYNX for VMS!!!

lynx.exe : library exe
	@ Continue

library :
	Set Default [.www.library.implementation]
.ifdef DEC_C
	$(MMS) $(MMSQUALIFIERS) /Description = [-.VMS]DESCRIP.MMS /Macro = ($(TCPM)=1, DEC_C=1) Library
.else
.ifdef GNU_C
	$(MMS) $(MMSQUALIFIERS) /Description = [-.VMS]DESCRIP.MMS /Macro = ($(TCPM)=1, GNU_C=1) Library
.else
	$(MMS) $(MMSQUALIFIERS) /Description = [-.VMS]DESCRIP.MMS /Macro = ($(TCPM)=1) Library
.endif
.endif
	Set Default [---]

exe :
	Set Default [.src]
.ifdef DEC_C
	$(MMS) $(MMSQUALIFIERS) /Macro = ($(TCPM)=1, DEC_C=1) Lynx
.else
.ifdef GNU_C
	$(MMS) $(MMSQUALIFIERS) /Macro = ($(TCPM)=1, GNU_C=1) Lynx
.else
	$(MMS) $(MMSQUALIFIERS) /Macro = ($(TCPM)=1) Lynx
.endif
.endif
	Copy /NoLog /NoConfirm lynx.exe [-]
	Set Protection = (Owner:RWE, World:RE) [-]lynx.exe
	Set Default [-]

clean :
	Set Default [.www.library.implementation]
	$(MMS) $(MMSQUALIFIERS) /Description = [-.VMS]DESCRIP.MMS clean
	Set Default [---]
	Set Default [.src]
	$(MMS) $(MMSQUALIFIERS) clean
	Set Default [-]
	- Purge /NoLog /NoConfirm