]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/tls.c
Add ber_bvstr and ber_bvstrdup string to berval allocators.
[openldap] / libraries / libldap / tls.c
index a00ad4525f3eb08363ec4174f16c806453394113..ba0a9e69474091dae2251d4940ca57bf8b6526d8 100644 (file)
@@ -110,6 +110,7 @@ ldap_pvt_tls_init( void )
 
        if ( tls_initialized )
                return -1;
+       tls_initialized = 1;
 #ifdef LDAP_R_COMPILE
        tls_init_threads();
 #endif
@@ -211,6 +212,10 @@ ldap_pvt_tls_init_def_ctx( void )
 #endif
        return 0;
 error_exit:
+       if ( tls_def_ctx != NULL ) {
+               SSL_CTX_free( tls_def_ctx );
+               tls_def_ctx = NULL;
+       }
 #ifdef LDAP_R_COMPILE
        ldap_pvt_thread_mutex_unlock( &tls_def_ctx_mutex );
 #endif
@@ -355,6 +360,14 @@ ldap_pvt_tls_accept( Sockbuf *sb, void *ctx_arg )
        return 0;
 }
 
+int
+ldap_pvt_tls_inplace ( Sockbuf *sb )
+{
+       if ( HAS_TLS( sb ) )
+               return(1);
+       return(0);
+}
+
 const char *
 ldap_pvt_tls_get_peer( LDAP *ld )
 {
@@ -496,6 +509,24 @@ ldap_pvt_tls_set_option( struct ldapoptions *lo, int option, void *arg )
        return 0;
 }
 
+int
+ldap_pvt_tls_start ( Sockbuf *sb, void *ctx_arg )
+{
+       /*
+        * Fortunately, the lib uses blocking io...
+        */
+       if ( ldap_pvt_tls_connect( sb, ctx_arg ) < 0 ) {
+               return LDAP_CONNECT_ERROR;
+       }
+
+       /* FIXME: hostname of server must be compared with name in
+        * certificate....
+        */
+
+       return LDAP_SUCCESS;
+}
+
+
 static int
 tls_setup( Sockbuf *sb, void *arg )
 {