ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/src/server.c
(Generate patch)

Comparing ircd-hybrid/trunk/src/s_serv.c (file contents):
Revision 2345 by michael, Wed Jul 3 18:17:39 2013 UTC vs.
Revision 2463 by michael, Sat Aug 17 20:38:00 2013 UTC

# Line 1305 | Line 1305 | finish_ssl_server_handshake(struct Clien
1305   static void
1306   ssl_server_handshake(fde_t *fd, struct Client *client_p)
1307   {
1308 <  int ret;
1309 <  int err;
1308 >  X509 *cert = NULL;
1309 >  int ret = 0;
1310  
1311 <  ret = SSL_connect(client_p->localClient->fd.ssl);
1312 <
1313 <  if (ret <= 0)
1311 >  if ((ret = SSL_connect(client_p->localClient->fd.ssl)) <= 0)
1312    {
1313 <    switch ((err = SSL_get_error(client_p->localClient->fd.ssl, ret)))
1313 >    switch (SSL_get_error(client_p->localClient->fd.ssl, ret))
1314      {
1315        case SSL_ERROR_WANT_WRITE:
1316          comm_setselect(&client_p->localClient->fd, COMM_SELECT_WRITE,
# Line 1334 | Line 1332 | ssl_server_handshake(fde_t *fd, struct C
1332      }
1333    }
1334  
1335 +  if ((cert = SSL_get_peer_certificate(client_p->localClient->fd.ssl)))
1336 +  {
1337 +    int res = SSL_get_verify_result(client_p->localClient->fd.ssl);
1338 +    char buf[EVP_MAX_MD_SIZE * 2 + 1] = { '\0' };
1339 +    unsigned char md[EVP_MAX_MD_SIZE] = { '\0' };
1340 +
1341 +    if (res == X509_V_OK || res == X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN ||
1342 +        res == X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE ||
1343 +        res == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT)
1344 +    {
1345 +      unsigned int i = 0, n = 0;
1346 +
1347 +      if (X509_digest(cert, EVP_sha256(), md, &n))
1348 +      {
1349 +        for (; i < n; ++i)
1350 +          snprintf(buf + 2 * i, 3, "%02X", md[i]);
1351 +        client_p->certfp = xstrdup(buf);
1352 +      }
1353 +    }
1354 +    else
1355 +      ilog(LOG_TYPE_IRCD, "Server %s!%s@%s gave bad SSL client certificate: %d",
1356 +           client_p->name, client_p->username, client_p->host, res);
1357 +    X509_free(cert);
1358 +  }
1359 +
1360    finish_ssl_server_handshake(client_p);
1361   }
1362  

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)