Put SSL errors into Module-Failure-Message
[freeradius.git] / src / modules / rlm_eap / libeap / eap_tls.c
index 73e027b..6983713 100644 (file)
@@ -125,7 +125,7 @@ int eaptls_success(EAP_HANDLER *handler, int peap_flag)
         *      user.
         */
        if ((!tls_session->allow_session_resumption) ||
-           (((vp = pairfind(request->config_items, 1127)) != NULL) &&
+           (((vp = pairfind(request->config_items, 1127, 0)) != NULL) &&
             (vp->vp_integer == 0))) {
                SSL_CTX_remove_session(tls_session->ctx,
                                       tls_session->ssl->session);
@@ -147,15 +147,19 @@ int eaptls_success(EAP_HANDLER *handler, int peap_flag)
        } else if (!SSL_session_reused(tls_session->ssl)) {
                RDEBUG2("Saving response in the cache");
                
-               vp = paircopy2(request->reply->vps, PW_USER_NAME);
+               vp = paircopy2(request->reply->vps, PW_USER_NAME, 0);
                pairadd(&vps, vp);
                
-               vp = paircopy2(request->packet->vps, PW_STRIPPED_USER_NAME);
+               vp = paircopy2(request->packet->vps, PW_STRIPPED_USER_NAME, 0);
                pairadd(&vps, vp);
                
                if (vps) {
                        SSL_SESSION_set_ex_data(tls_session->ssl->session,
                                                eaptls_session_idx, vps);
+               } else {
+                       RDEBUG2("WARNING: No information to cache: session caching will be disabled for this session.");
+                       SSL_CTX_remove_session(tls_session->ctx,
+                                              tls_session->ssl->session);
                }
 
                /*
@@ -168,6 +172,7 @@ int eaptls_success(EAP_HANDLER *handler, int peap_flag)
                                             eaptls_session_idx);
                if (!vp) {
                        RDEBUG("WARNING: No information in cached session!");
+                       return eaptls_fail(handler, peap_flag);
                } else {
                        RDEBUG("Adding cached attributes to the reply:");
                        debug_pair_list(vp);
@@ -176,7 +181,7 @@ int eaptls_success(EAP_HANDLER *handler, int peap_flag)
                        /*
                         *      Mark the request as resumed.
                         */
-                       vp = pairmake("EAP-Session-Resumed", "0", T_OP_SET);
+                       vp = pairmake("EAP-Session-Resumed", "1", T_OP_SET);
                        if (vp) pairadd(&request->packet->vps, vp);
                }
        }
@@ -755,7 +760,7 @@ static eaptls_status_t eaptls_operation(eaptls_status_t status,
         *      If more info
         *      is required then send another request.
         */
-       if (!tls_handshake_recv(tls_session)) {
+       if (!tls_handshake_recv(handler->request, tls_session)) {
                DEBUG2("TLS receive handshake failed during operation");
                eaptls_fail(handler, tls_session->peap_flag);
                return EAPTLS_FAIL;