~ubuntu-branches/ubuntu/vivid/dovecot/vivid

« back to all changes in this revision

Viewing changes to src/login-common/ssl-proxy-gnutls.c

  • Committer: Bazaar Package Importer
  • Author(s): Jaldhar H. Vyas
  • Date: 2005-11-05 23:19:19 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20051105231919-ydujs4y7687fpor2
Tags: upstream-1.0.alpha4
ImportĀ upstreamĀ versionĀ 1.0.alpha4

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
#ifdef HAVE_GNUTLS
10
10
 
 
11
#error broken currently
 
12
 
11
13
#include <stdio.h>
12
14
#include <stdlib.h>
13
15
#include <unistd.h>
78
80
        }
79
81
 
80
82
        if (verbose_ssl) {
81
 
                /* fatal error occured */
 
83
                /* fatal error occurred */
82
84
                if (error == GNUTLS_E_FATAL_ALERT_RECEIVED) {
83
85
                        i_warning("Received SSL fatal alert: %s [%s]",
84
86
                                  get_alert_text(proxy),
276
278
                return;
277
279
 
278
280
        /* i/o interrupted */
279
 
        dir = gnutls_handshake_get_direction(proxy->session) == 0 ?
 
281
        dir = gnutls_record_get_direction(proxy->session) == 0 ?
280
282
                IO_READ : IO_WRITE;
281
283
        if (proxy->io_ssl_dir != dir) {
282
284
                if (proxy->io_ssl != NULL)
298
300
        gnutls_compression_set_priority(session, comp_priority);
299
301
        gnutls_kx_set_priority(session, kx_priority);
300
302
        gnutls_mac_set_priority(session, mac_priority);
301
 
        gnutls_cert_type_set_priority(session, cert_type_priority);
 
303
        gnutls_certificate_type_set_priority(session, cert_type_priority);
302
304
 
303
305
        gnutls_cred_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
304
306
        return session;
310
312
        gnutls_session session;
311
313
        int sfd[2];
312
314
 
313
 
        if (!ssl_initialized)
 
315
        if (!ssl_initialized) {
 
316
                i_error("SSL support not enabled in configuration");
314
317
                return -1;
 
318
        }
315
319
 
316
320
        session = initialize_state();
317
321
        gnutls_transport_set_ptr(session, fd);
504
508
 
505
509
        read_parameters(paramfile);
506
510
 
507
 
        if ((ret = gnutls_certificate_allocate_cred(&x509_cred)) < 0) {
508
 
                i_fatal("gnutls_certificate_allocate_cred() failed: %s",
 
511
        if ((ret = gnutls_certificate_allocate_credentials(&x509_cred)) < 0) {
 
512
                i_fatal("gnutls_certificate_allocate_credentials() failed: %s",
509
513
                        gnutls_strerror(ret));
510
514
        }
511
515
 
516
520
                        certfile, keyfile, gnutls_strerror(ret));
517
521
        }
518
522
 
519
 
        ret = gnutls_certificate_set_dh_params(x509_cred, dh_params);
520
 
        if (ret < 0)
521
 
                i_fatal("Can't set DH parameters: %s", gnutls_strerror(ret));
522
 
        ret = gnutls_certificate_set_rsa_params(x509_cred, rsa_params);
523
 
        if (ret < 0)
524
 
                i_fatal("Can't set RSA parameters: %s", gnutls_strerror(ret));
 
523
        gnutls_certificate_set_dh_params(x509_cred, dh_params);
 
524
        gnutls_certificate_set_rsa_export_params(x509_cred, rsa_params);
525
525
 
526
526
        ssl_proxies = hash_create(default_pool, default_pool, 0, NULL, NULL);
527
527
        ssl_initialized = TRUE;
528
528
}
529
529
 
530
 
static void ssl_proxy_destroy_hash(void *key __attr_unused__, void *value,
531
 
                                   void *context __attr_unused__)
532
 
{
533
 
        ssl_proxy_destroy(value);
534
 
}
535
 
 
536
530
void ssl_proxy_deinit(void)
537
531
{
 
532
        struct hash_iterate_context *iter;
 
533
        void *key, *value;
 
534
 
538
535
        if (!ssl_initialized)
539
536
                return;
540
537
 
541
 
        hash_foreach(ssl_proxies, ssl_proxy_destroy_hash, NULL);
 
538
        iter = hash_iterate_init(ssl_proxies);
 
539
        while (hash_iterate(iter, &key, &value))
 
540
                ssl_proxy_destroy(value);
 
541
        hash_iterate_deinit(iter);
542
542
        hash_destroy(ssl_proxies);
543
543
 
544
 
        gnutls_certificate_free_cred(x509_cred);
 
544
        gnutls_certificate_free_credentials(x509_cred);
545
545
        gnutls_global_deinit();
546
546
}
547
547