~ubuntu-branches/ubuntu/saucy/postfix/saucy

« back to all changes in this revision

Viewing changes to src/tls/tls_client.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2011-02-22 11:20:43 UTC
  • mfrom: (1.1.27 upstream)
  • Revision ID: james.westby@ubuntu.com-20110222112043-c34ht219w3ybrilr
Tags: 2.8.0-2
* a little more lintian cleanup
* Fix missing format strings in smtp-sink.c

Show diffs side-by-side

added added

removed removed

Lines of Context:
139
139
#include <vstream.h>
140
140
#include <stringops.h>
141
141
#include <msg.h>
 
142
#include <iostuff.h>                    /* non-blocking */
142
143
 
143
144
/* Global library. */
144
145
 
818
819
               | ((protomask & TLS_PROTOCOL_SSLv2) ? SSL_OP_NO_SSLv2 : 0L));
819
820
 
820
821
    /*
821
 
     * The TLS connection is realized by a BIO_pair, so obtain the pair.
822
 
     * 
823
 
     * XXX There is no need to make internal_bio a member of the TLScontext
824
 
     * structure. It will be attached to TLScontext->con, and destroyed along
825
 
     * with it. The network_bio, however, needs to be freed explicitly.
826
 
     */
827
 
    if (!BIO_new_bio_pair(&TLScontext->internal_bio, TLS_BIO_BUFSIZE,
828
 
                          &TLScontext->network_bio, TLS_BIO_BUFSIZE)) {
829
 
        msg_warn("Could not obtain BIO_pair");
830
 
        tls_print_errors();
831
 
        tls_free_context(TLScontext);
832
 
        return (0);
833
 
    }
834
 
 
835
 
    /*
836
822
     * XXX To avoid memory leaks we must always call SSL_SESSION_free() after
837
823
     * calling SSL_set_session(), regardless of whether or not the session
838
824
     * will be reused.
876
862
    SSL_set_connect_state(TLScontext->con);
877
863
 
878
864
    /*
879
 
     * Connect the SSL connection with the Postfix side of the BIO-pair for
880
 
     * reading and writing.
881
 
     */
882
 
    SSL_set_bio(TLScontext->con, TLScontext->internal_bio,
883
 
                TLScontext->internal_bio);
 
865
     * Connect the SSL connection with the network socket.
 
866
     */
 
867
    if (SSL_set_fd(TLScontext->con, vstream_fileno(props->stream)) != 1) {
 
868
        msg_info("SSL_set_fd error to %s", props->namaddr);
 
869
        tls_print_errors();
 
870
        uncache_session(app_ctx->ssl_ctx, TLScontext);
 
871
        tls_free_context(TLScontext);
 
872
        return (0);
 
873
    }
 
874
 
 
875
    /*
 
876
     * Turn on non-blocking I/O so that we can enforce timeouts on network
 
877
     * I/O.
 
878
     */
 
879
    non_blocking(vstream_fileno(props->stream), NON_BLOCKING);
884
880
 
885
881
    /*
886
882
     * If the debug level selected is high enough, all of the data is dumped: