Skip to content

Commit

Permalink
Fixing typos and more error checks
Browse files Browse the repository at this point in the history
  • Loading branch information
eaescob committed Dec 3, 2023
1 parent 3ba54e0 commit d637ef2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/m_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ do_server_estab(aClient *cptr)
sendto_gnotice("from %s: Link with %s established, states:%s%s%s%s",
me.name, inpath, ZipOut(cptr) ? " Output-compressed" : "",
#ifdef USE_SSL
IsSSL(cptr) ? " encrypted" : "",
(IsSSL(cptr) || RC4EncLink(cptr))? " encrypted" : "",
#else
RC4EncLink(cptr) ? " encrypted" : "",
#endif
Expand Down
10 changes: 6 additions & 4 deletions src/s_bsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ static char readbuf[8192];
#endif
#endif

#ifdef USE_SSL
extern int mydata_index;
#endif

/*
* add_local_domain()
* Add the domain to hostname, if it is missing
Expand Down Expand Up @@ -901,7 +905,7 @@ int completed_connection(aClient * cptr)
" NICKIP NICKIPSTR TSMODE");
else
{
sendto_one(cptr, "CAPAB SSJOIN NOQUIT BURTS UNCONNECT DKEY"
sendto_one(cptr, "CAPAB SSJOIN NOQUIT BURST UNCONNECT DKEY"
" ZIP NICKIP NICKIPSTR TSMODE");
SetWantDKEY(cptr);
}
Expand Down Expand Up @@ -1986,11 +1990,9 @@ int connect_server(aConnect *aconn, aClient * by, struct hostent *hp)

SetSSL(cptr);
SSL_set_fd(cptr->ssl, cptr->fd);
extern int mydata_index;


int ret=0;

mydata_index = SSL_get_ex_new_index(0, "mydata index", NULL, NULL, NULL);
/*
* Set the aConn object as SSL data for the verification
*/
Expand Down
13 changes: 13 additions & 0 deletions src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ int ssl_init()
return 0;
}

mydata_index = SSL_get_ex_new_index(0, "aConn data", NULL, NULL, NULL);

return 1;
}

Expand Down Expand Up @@ -474,10 +476,21 @@ int ssl_verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
*/

X509_NAME *subj = X509_get_subject_name(cert);

if (!subj) return preverify_ok;

X509_NAME_ENTRY *e = X509_NAME_get_entry(subj, 5);

if (!e) return preverify_ok;

ASN1_STRING *d = X509_NAME_ENTRY_get_data(e);

if (!d) return preverify_ok;

char *cn = ASN1_STRING_data(d);

if (!cn) return preverify_ok;

if (!mycmp(cn, conn->name))
{
sendto_realops_lev(DEBUG_LEV, "SSL: Valid certificate cn: %s, name: %s", cn, conn->name);
Expand Down

0 comments on commit d637ef2

Please sign in to comment.