sufficiently configured. Update slapd/slurpd to act appropriately.
char *certfile = tls_opt_certfile;
char *keyfile = tls_opt_keyfile;
+#ifdef LDAP_R_COMPILE
+ ldap_pvt_thread_mutex_lock( &tls_def_ctx_mutex );
+#endif
+ if (( !cacertfile && !cacertdir ) || !certfile || !keyfile )
+ return LDAP_NOT_SUPPORTED;
+
#ifdef HAVE_EBCDIC
/* This ASCII/EBCDIC handling is a real pain! */
if ( ciphersuite ) {
__atoe( keyfile );
}
#endif
-
-#ifdef LDAP_R_COMPILE
- ldap_pvt_thread_mutex_lock( &tls_def_ctx_mutex );
-#endif
if ( tls_def_ctx == NULL ) {
int i;
tls_def_ctx = SSL_CTX_new( SSLv23_method() );
{ &slap_EXOP_CANCEL, SLAP_EXOP_HIDE, cancel_extop },
{ &slap_EXOP_WHOAMI, 0, whoami_extop },
{ &slap_EXOP_MODIFY_PASSWD, SLAP_EXOP_WRITES, passwd_extop },
-#ifdef HAVE_TLS
- { &slap_EXOP_START_TLS, 0, starttls_extop },
-#endif
{ NULL, 0, NULL }
};
ldap_pvt_tls_set_option( NULL, LDAP_OPT_X_TLS_CTX, NULL );
rc = ldap_pvt_tls_init_def_ctx();
- if( rc != 0) {
+ if( rc == 0) {
+ ldap_pvt_tls_get_option( NULL, LDAP_OPT_X_TLS_CTX, &slap_tls_ctx );
+ /* Restore previous ctx */
+ ldap_pvt_tls_set_option( NULL, LDAP_OPT_X_TLS_CTX, def_ctx );
+ load_extop( &slap_EXOP_START_TLS, 0, starttls_extop );
+ } else if ( rc != LDAP_NOT_SUPPORTED ) {
Debug( LDAP_DEBUG_ANY,
"main: TLS init def ctx failed: %d\n",
rc, 0, 0 );
SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 20 );
goto destroy;
}
- /* Retrieve slapd's own ctx */
- ldap_pvt_tls_get_option( NULL, LDAP_OPT_X_TLS_CTX, &slap_tls_ctx );
- /* Restore previous ctx */
- ldap_pvt_tls_set_option( NULL, LDAP_OPT_X_TLS_CTX, def_ctx );
}
#endif
#ifdef HAVE_TLS
if( ldap_pvt_tls_init() || ldap_pvt_tls_init_def_ctx() ) {
- fprintf( stderr, "TLS Initialization failed.\n" );
- SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 20 );
- rc = 1;
- goto stop;
+ rc = 0;
+ /* See if we actually need TLS */
+ for ( i=0; i < sglob->num_replicas; i++ ) {
+ if ( sglob->replicas[i]->ri_tls || ( sglob->replicas[i]->ri_uri &&
+ !strncmp( sglob->replicas[i]->ri_uri, "ldaps:", 6 ))) {
+ rc = 1;
+ break;
+ }
+ }
+ if ( rc ) {
+ fprintf( stderr, "TLS Initialization failed.\n" );
+ SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 20 );
+ goto stop;
+ }
}
#endif