~ubuntu-branches/ubuntu/saucy/curl/saucy-201307251546

« back to all changes in this revision

Viewing changes to lib/gtls.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2013-02-12 08:54:32 UTC
  • mfrom: (3.4.34 sid)
  • Revision ID: package-import@ubuntu.com-20130212085432-r1fyi0b37enr93pp
Tags: 7.29.0-1ubuntu1
* Resynchronise with Debian. Remaining changes:
  - Drop dependencies not in main:
    + Build-Depends: Drop stunnel4 and libssh2-1-dev.
    + Drop libssh2-1-dev from binary package Depends.
  - Add new libcurl3-udeb package.
  - Add new curl-udeb package.
* Add warning to debian/patches/series.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 * since they were not present in 1.0.X.
29
29
 */
30
30
 
31
 
#include "setup.h"
 
31
#include "curl_setup.h"
32
32
 
33
33
#ifdef USE_GNUTLS
34
34
 
35
35
#include <gnutls/gnutls.h>
36
36
#include <gnutls/x509.h>
 
37
 
37
38
#ifdef USE_GNUTLS_NETTLE
38
39
#include <gnutls/crypto.h>
39
40
#include <nettle/md5.h>
41
42
#include <gcrypt.h>
42
43
#endif
43
44
 
44
 
#ifdef HAVE_SYS_SOCKET_H
45
 
#include <sys/socket.h>
46
 
#endif
47
 
 
48
45
#include "urldata.h"
49
46
#include "sendf.h"
50
47
#include "inet_pton.h"
97
94
/*
98
95
 * Custom push and pull callback functions used by GNU TLS to read and write
99
96
 * to the socket.  These functions are simple wrappers to send() and recv()
100
 
 * (although here using the sread/swrite macros as defined by setup_once.h).
 
97
 * (although here using the sread/swrite macros as defined by
 
98
 * curl_setup_once.h).
101
99
 * We use custom functions rather than the GNU TLS defaults because it allows
102
100
 * us to get specific about the fourth "flags" argument, and to use arbitrary
103
101
 * private data with gnutls_transport_set_ptr if we wish.
304
302
        return CURLE_OK;
305
303
    }
306
304
    else if((rc < 0) && !gnutls_error_is_fatal(rc)) {
307
 
      failf(data, "gnutls_handshake() warning: %s", gnutls_strerror(rc));
 
305
      const char *strerr = NULL;
 
306
 
 
307
      if(rc == GNUTLS_E_WARNING_ALERT_RECEIVED) {
 
308
        int alert = gnutls_alert_get(session);
 
309
        strerr = gnutls_alert_get_name(alert);
 
310
      }
 
311
 
 
312
      if(strerr == NULL)
 
313
        strerr = gnutls_strerror(rc);
 
314
 
 
315
      failf(data, "gnutls_handshake() warning: %s", strerr);
308
316
    }
309
317
    else if(rc < 0) {
310
 
      failf(data, "gnutls_handshake() failed: %s", gnutls_strerror(rc));
 
318
      const char *strerr = NULL;
 
319
 
 
320
      if(rc == GNUTLS_E_FATAL_ALERT_RECEIVED) {
 
321
        int alert = gnutls_alert_get(session);
 
322
        strerr = gnutls_alert_get_name(alert);
 
323
      }
 
324
 
 
325
      if(strerr == NULL)
 
326
        strerr = gnutls_strerror(rc);
 
327
 
 
328
      failf(data, "gnutls_handshake() failed: %s", strerr);
311
329
      return CURLE_SSL_CONNECT_ERROR;
312
330
    }
313
331
 
661
679
  rc = gnutls_x509_crt_check_hostname(x509_cert, conn->host.name);
662
680
 
663
681
  if(!rc) {
664
 
    if(data->set.ssl.verifyhost > 1) {
 
682
    if(data->set.ssl.verifyhost) {
665
683
      failf(data, "SSL: certificate subject name (%s) does not match "
666
684
            "target host name '%s'", certbuf, conn->host.dispname);
667
685
      gnutls_x509_crt_deinit(x509_cert);