summaryrefslogtreecommitdiff
path: root/vchat-protocol.c
diff options
context:
space:
mode:
authorerdgeist <>2010-08-27 13:20:16 +0000
committererdgeist <>2010-08-27 13:20:16 +0000
commitedad5cf6e2b7604204d6246be5fe6b6dd8532fa0 (patch)
treed47c713620fcaa097ea66c19b285bb8be62c2f03 /vchat-protocol.c
parent6eb716f8db302dcf51113a7f8c99c18ebcb6b07e (diff)
Tidy up ssl code, move all ssl related stuff to vchat-ssl and clean up some wrinkles in cert verification
Diffstat (limited to 'vchat-protocol.c')
-rwxr-xr-xvchat-protocol.c42
1 files changed, 16 insertions, 26 deletions
diff --git a/vchat-protocol.c b/vchat-protocol.c
index 700f6c7..ef035fe 100755
--- a/vchat-protocol.c
+++ b/vchat-protocol.c
@@ -70,7 +70,6 @@ static void pmnotsent (char *message);
70/* status-variable from vchat-client.c 70/* status-variable from vchat-client.c
71 * eventloop is done as long as this is true */ 71 * eventloop is done as long as this is true */
72extern int status; 72extern int status;
73int ignssl = 0;
74char *encoding; 73char *encoding;
75 74
76static int connect_socket( char *server, char *port ) { 75static int connect_socket( char *server, char *port ) {
@@ -107,9 +106,6 @@ vcconnect (char *server, char *port)
107 /* vchat connection x509 store */ 106 /* vchat connection x509 store */
108 vc_x509store_t vc_store; 107 vc_x509store_t vc_store;
109 108
110 /* SSL-context */
111 SSL_CTX *sslctx = NULL;
112
113 /* pointer to tilde-expanded certificate/keyfile-names */ 109 /* pointer to tilde-expanded certificate/keyfile-names */
114 char *certfile = NULL, *keyfile = NULL; 110 char *certfile = NULL, *keyfile = NULL;
115 111
@@ -164,10 +160,9 @@ vcconnect (char *server, char *port)
164 vc_x509store_set_pkeycb(&vc_store, (vc_askpass_cb_t)passprompt); 160 vc_x509store_set_pkeycb(&vc_store, (vc_askpass_cb_t)passprompt);
165 vc_x509store_setkeyfile(&vc_store, tildex); 161 vc_x509store_setkeyfile(&vc_store, tildex);
166 } 162 }
167 vc_x509store_setignssl(&vc_store, getintoption(CF_IGNSSL));
168 163
169 /* upgrade our plain BIO to ssl */ 164 /* upgrade our plain BIO to ssl */
170 if( vc_connect_ssl( &server_conn, &vc_store, &sslctx ) ) 165 if( vc_connect_ssl( &server_conn, &vc_store ) )
171 BIO_free_all( server_conn ); 166 BIO_free_all( server_conn );
172 } 167 }
173 168
@@ -279,7 +274,7 @@ topicinfo (char *message)
279{ 274{
280 char *channel = NULL, *topic = NULL; 275 char *channel = NULL, *topic = NULL;
281 int tmpchan = 0; 276 int tmpchan = 0;
282 277
283 /* search start of channel number */ 278 /* search start of channel number */
284 channel = strchr (message, ' '); 279 channel = strchr (message, ' ');
285 channel++; 280 channel++;
@@ -443,7 +438,7 @@ nickerr (char *message)
443 setstroption(CF_NICK,NULL); 438 setstroption(CF_NICK,NULL);
444 /* get new nick via vchat-ui.c */ 439 /* get new nick via vchat-ui.c */
445 nickprompt (); 440 nickprompt ();
446 441
447 /* form login message and send it to server */ 442 /* form login message and send it to server */
448 snprintf (tmpstr, TMPSTRSIZE, ".l %s %s %d", nick, getstroption (CF_FROM), getintoption (CF_CHANNEL)); 443 snprintf (tmpstr, TMPSTRSIZE, ".l %s %s %d", nick, getstroption (CF_FROM), getintoption (CF_CHANNEL));
449 networkoutput (tmpstr); 444 networkoutput (tmpstr);
@@ -455,8 +450,7 @@ nickerr (char *message)
455 * vars: %s - this users registered nick 450 * vars: %s - this users registered nick
456 * %s msg - server message */ 451 * %s msg - server message */
457static void 452static void
458login (char *message) 453login (char *message) {
459{
460 char *msg = NULL; 454 char *msg = NULL;
461 455
462 /* mutate message for output */ 456 /* mutate message for output */
@@ -465,23 +459,19 @@ login (char *message)
465 writecf (FS_SERV,&message[2]); 459 writecf (FS_SERV,&message[2]);
466 460
467 /* we don't know our nick? */ 461 /* we don't know our nick? */
468 if (!nick) 462 if (!nick) {
469 { 463 /* find message after nick */
470 /* find message after nick */ 464 msg = strchr (&message[4], ' ');
471 msg = strchr (&message[4], ' '); 465 if (msg) {
472 if (msg) 466 /* terminate string before message and copy nick */
473 { 467 msg[0] = '\0';
474 /* terminate string before message and copy nick */ 468 setstroption(CF_NICK,&message[4]);
475 msg[0] = '\0'; 469 } else {
476 setstroption(CF_NICK,&message[4]); 470 /* no string in servers message (huh?), ask user for nick */
477 } 471 nickprompt ();
478 else
479 {
480 /* no string in servers message (huh?), ask user for nick */
481 nickprompt ();
482 }
483 } 472 }
484 473 }
474
485 /* form login message and send it to server */ 475 /* form login message and send it to server */
486 snprintf (tmpstr, TMPSTRSIZE, ".l %s %s %d", nick, getstroption (CF_FROM), getintoption (CF_CHANNEL)); 476 snprintf (tmpstr, TMPSTRSIZE, ".l %s %s %d", nick, getstroption (CF_FROM), getintoption (CF_CHANNEL));
487 networkoutput (tmpstr); 477 networkoutput (tmpstr);