Changeset View
Changeset View
Standalone View
Standalone View
src/ldapconnection.cpp
Show First 20 Lines • Show All 273 Lines • ▼ Show 20 Line(s) | 273 | d->mConnectionError = i18np("Cannot set timeout to %1 second.", | |||
---|---|---|---|---|---|
274 | "Cannot set timeout to %1 seconds.", | 274 | "Cannot set timeout to %1 seconds.", | ||
275 | timeout); | 275 | timeout); | ||
276 | close(); | 276 | close(); | ||
277 | return ret; | 277 | return ret; | ||
278 | } | 278 | } | ||
279 | } | 279 | } | ||
280 | #endif | 280 | #endif | ||
281 | 281 | | |||
282 | //FIXME: accessing to certificate handling would be good | | |||
283 | qCDebug(LDAP_LOG) << "setting security to:" << d->mServer.security(); | 282 | qCDebug(LDAP_LOG) << "setting security to:" << d->mServer.security(); | ||
284 | if (d->mServer.security() == LdapServer::TLS) { | 283 | if (d->mServer.security() != LdapServer::None) { | ||
285 | bool initContext = false; | 284 | bool initContext = false; | ||
286 | if (d->mServer.tlsCACertFile().isEmpty() == false) { | 285 | if (d->mServer.tlsCACertFile().isEmpty() == false) { | ||
287 | if (setOption(LDAP_OPT_X_TLS_CACERTFILE, d->mServer.tlsCACertFile().toUtf8().data()) != LDAP_OPT_SUCCESS) { | 286 | if (setOption(LDAP_OPT_X_TLS_CACERTFILE, d->mServer.tlsCACertFile().toUtf8().data()) != LDAP_OPT_SUCCESS) { | ||
288 | d->mConnectionError = i18n("Could not set CA certificate file."); | 287 | d->mConnectionError = i18n("Could not set CA certificate file."); | ||
289 | return -1; | 288 | return -1; | ||
290 | } | 289 | } | ||
291 | initContext = true; | 290 | initContext = true; | ||
292 | } | 291 | } | ||
Show All 30 Lines | |||||
323 | 322 | | |||
324 | if (initContext) { | 323 | if (initContext) { | ||
325 | int isServer = 0; | 324 | int isServer = 0; | ||
326 | if (setOption(LDAP_OPT_X_TLS_NEWCTX, &isServer) != LDAP_OPT_SUCCESS) { | 325 | if (setOption(LDAP_OPT_X_TLS_NEWCTX, &isServer) != LDAP_OPT_SUCCESS) { | ||
327 | d->mConnectionError = i18n("Could not initialize new TLS context."); | 326 | d->mConnectionError = i18n("Could not initialize new TLS context."); | ||
328 | return -1; | 327 | return -1; | ||
329 | } | 328 | } | ||
330 | } | 329 | } | ||
330 | } | ||||
331 | 331 | | |||
332 | if (d->mServer.security() == LdapServer::TLS) { | ||||
332 | qCDebug(LDAP_LOG) << "start TLS"; | 333 | qCDebug(LDAP_LOG) << "start TLS"; | ||
333 | 334 | | |||
334 | #ifdef HAVE_LDAP_START_TLS_S | 335 | #ifdef HAVE_LDAP_START_TLS_S | ||
335 | if ((ret = ldap_start_tls_s(d->mLDAP, nullptr, nullptr)) != LDAP_SUCCESS) { | 336 | if ((ret = ldap_start_tls_s(d->mLDAP, nullptr, nullptr)) != LDAP_SUCCESS) { | ||
336 | d->mConnectionError = ldapErrorString(); | 337 | d->mConnectionError = ldapErrorString(); | ||
337 | close(); | 338 | close(); | ||
338 | return ret; | 339 | return ret; | ||
339 | } | 340 | } | ||
▲ Show 20 Lines • Show All 121 Lines • Show Last 20 Lines |