Remove redundant call to set_psk_client_callback()
[freeradius.git] / src / main / tls_listen.c
1 /*
2  * tls.c
3  *
4  * Version:     $Id$
5  *
6  *   This program is free software; you can redistribute it and/or modify
7  *   it under the terms of the GNU General Public License as published by
8  *   the Free Software Foundation; either version 2 of the License, or
9  *   (at your option) any later version.
10  *
11  *   This program is distributed in the hope that it will be useful,
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *   GNU General Public License for more details.
15  *
16  *   You should have received a copy of the GNU General Public License
17  *   along with this program; if not, write to the Free Software
18  *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  *
20  * Copyright 2001  hereUare Communications, Inc. <raghud@hereuare.com>
21  * Copyright 2003  Alan DeKok <aland@freeradius.org>
22  * Copyright 2006  The FreeRADIUS server project
23  */
24
25 RCSID("$Id$")
26 USES_APPLE_DEPRECATED_API       /* OpenSSL API has been deprecated by Apple */
27
28 #include <freeradius-devel/radiusd.h>
29 #include <freeradius-devel/process.h>
30 #include <freeradius-devel/rad_assert.h>
31
32 #ifdef HAVE_SYS_STAT_H
33 #include <sys/stat.h>
34 #endif
35
36 #ifdef WITH_TLS
37 #ifdef HAVE_OPENSSL_RAND_H
38 #include <openssl/rand.h>
39 #endif
40
41 #ifdef HAVE_OPENSSL_OCSP_H
42 #include <openssl/ocsp.h>
43 #endif
44
45 #ifdef HAVE_PTHREAD_H
46 #define PTHREAD_MUTEX_LOCK pthread_mutex_lock
47 #define PTHREAD_MUTEX_UNLOCK pthread_mutex_unlock
48 #else
49 #define PTHREAD_MUTEX_LOCK(_x)
50 #define PTHREAD_MUTEX_UNLOCK(_x)
51 #endif
52
53 static void dump_hex(char const *msg, uint8_t const *data, size_t data_len)
54 {
55         size_t i;
56
57         if (debug_flag < 3) return;
58
59         printf("%s %d\n", msg, (int) data_len);
60         if (data_len > 256) data_len = 256;
61
62         for (i = 0; i < data_len; i++) {
63                 if ((i & 0x0f) == 0x00) printf ("%02x: ", (unsigned int) i);
64                 printf("%02x ", data[i]);
65                 if ((i & 0x0f) == 0x0f) printf ("\n");
66         }
67         printf("\n");
68         fflush(stdout);
69 }
70
71 static void tls_socket_close(rad_listen_t *listener)
72 {
73         listen_socket_t *sock = listener->data;
74
75         SSL_shutdown(sock->ssn->ssl);
76
77
78         listener->status = RAD_LISTEN_STATUS_EOL;
79         listener->tls = NULL; /* parent owns this! */
80
81         /*
82          *      Tell the event handler that an FD has disappeared.
83          */
84         DEBUG("Client has closed connection");
85         radius_update_listener(listener);
86
87         /*
88          *      Do NOT free the listener here.  It's in use by
89          *      a request, and will need to hang around until
90          *      all of the requests are done.
91          *
92          *      It is instead free'd in remove_from_request_hash()
93          */
94 }
95
96 static int CC_HINT(nonnull) tls_socket_write(rad_listen_t *listener, REQUEST *request)
97 {
98         uint8_t *p;
99         ssize_t rcode;
100         listen_socket_t *sock = listener->data;
101
102         p = sock->ssn->dirty_out.data;
103
104         while (p < (sock->ssn->dirty_out.data + sock->ssn->dirty_out.used)) {
105                 RDEBUG3("Writing to socket %d", request->packet->sockfd);
106                 rcode = write(request->packet->sockfd, p,
107                               (sock->ssn->dirty_out.data + sock->ssn->dirty_out.used) - p);
108                 if (rcode <= 0) {
109                         RDEBUG("Error writing to TLS socket: %s", fr_syserror(errno));
110
111                         tls_socket_close(listener);
112                         return 0;
113                 }
114                 p += rcode;
115         }
116
117         sock->ssn->dirty_out.used = 0;
118
119         return 1;
120 }
121
122
123 static int tls_socket_recv(rad_listen_t *listener)
124 {
125         bool doing_init = false;
126         ssize_t rcode;
127         RADIUS_PACKET *packet;
128         REQUEST *request;
129         listen_socket_t *sock = listener->data;
130         fr_tls_status_t status;
131         RADCLIENT *client = sock->client;
132
133         if (!sock->packet) {
134                 sock->packet = rad_alloc(sock, false);
135                 if (!sock->packet) return 0;
136
137                 sock->packet->sockfd = listener->fd;
138                 sock->packet->src_ipaddr = sock->other_ipaddr;
139                 sock->packet->src_port = sock->other_port;
140                 sock->packet->dst_ipaddr = sock->my_ipaddr;
141                 sock->packet->dst_port = sock->my_port;
142
143                 if (sock->request) {
144                         sock->request->packet = talloc_steal(sock->request, sock->packet);
145                 }
146         }
147
148         /*
149          *      Allocate a REQUEST for debugging.
150          */
151         if (!sock->request) {
152                 sock->request = request = request_alloc(NULL);
153                 if (!sock->request) {
154                         ERROR("Out of memory");
155                         return 0;
156                 }
157
158                 rad_assert(request->packet == NULL);
159                 rad_assert(sock->packet != NULL);
160                 request->packet = talloc_steal(request, sock->packet);
161
162                 request->component = "<core>";
163                 request->component = "<tls-connect>";
164
165                 /*
166                  *      Not sure if we should do this on every packet...
167                  */
168                 request->reply = rad_alloc(request, false);
169                 if (!request->reply) return 0;
170
171                 rad_assert(sock->ssn == NULL);
172
173                 sock->ssn = tls_new_session(listener->tls, listener->tls, sock->request,
174                                             listener->tls->require_client_cert);
175                 if (!sock->ssn) {
176                         TALLOC_FREE(sock->request);
177                         sock->packet = NULL;
178                         return 0;
179                 }
180
181                 (void) talloc_steal(sock, sock->ssn);
182                 SSL_set_ex_data(sock->ssn->ssl, FR_TLS_EX_INDEX_REQUEST, (void *)request);
183                 SSL_set_ex_data(sock->ssn->ssl, FR_TLS_EX_INDEX_CERTS, (void *)&request->packet->vps);
184                 SSL_set_ex_data(sock->ssn->ssl, FR_TLS_EX_INDEX_TALLOC, sock->parent);
185
186                 doing_init = true;
187         }
188
189         rad_assert(sock->request != NULL);
190         rad_assert(sock->request->packet != NULL);
191         rad_assert(sock->packet != NULL);
192         rad_assert(sock->ssn != NULL);
193
194         request = sock->request;
195
196         RDEBUG3("Reading from socket %d", request->packet->sockfd);
197         PTHREAD_MUTEX_LOCK(&sock->mutex);
198         rcode = read(request->packet->sockfd,
199                      sock->ssn->dirty_in.data,
200                      sizeof(sock->ssn->dirty_in.data));
201         if ((rcode < 0) && (errno == ECONNRESET)) {
202         do_close:
203                 DEBUG("Closing TLS socket from client port %u", sock->other_port);
204                 tls_socket_close(listener);
205                 PTHREAD_MUTEX_UNLOCK(&sock->mutex);
206                 return 0;
207         }
208
209         if (rcode < 0) {
210                 RDEBUG("Error reading TLS socket: %s", fr_syserror(errno));
211                 goto do_close;
212         }
213
214         /*
215          *      Normal socket close.
216          */
217         if (rcode == 0) goto do_close;
218
219         sock->ssn->dirty_in.used = rcode;
220
221         dump_hex("READ FROM SSL", sock->ssn->dirty_in.data, sock->ssn->dirty_in.used);
222
223         /*
224          *      Catch attempts to use non-SSL.
225          */
226         if (doing_init && (sock->ssn->dirty_in.data[0] != handshake)) {
227                 RDEBUG("Non-TLS data sent to TLS socket: closing");
228                 goto do_close;
229         }
230
231         /*
232          *      Skip ahead to reading application data.
233          */
234         if (SSL_is_init_finished(sock->ssn->ssl)) goto app;
235
236         if (!tls_handshake_recv(request, sock->ssn)) {
237                 RDEBUG("FAILED in TLS handshake receive");
238                 goto do_close;
239         }
240
241         if (sock->ssn->dirty_out.used > 0) {
242                 tls_socket_write(listener, request);
243                 PTHREAD_MUTEX_UNLOCK(&sock->mutex);
244                 return 0;
245         }
246
247 app:
248         /*
249          *      FIXME: Run the packet through a virtual server in
250          *      order to see if we like the certificate presented by
251          *      the client.
252          */
253
254         status = tls_application_data(sock->ssn, request);
255         RDEBUG("Application data status %d", status);
256
257         if (status == FR_TLS_MORE_FRAGMENTS) {
258                 PTHREAD_MUTEX_UNLOCK(&sock->mutex);
259                 return 0;
260         }
261
262         if (sock->ssn->clean_out.used == 0) {
263                 PTHREAD_MUTEX_UNLOCK(&sock->mutex);
264                 return 0;
265         }
266
267         dump_hex("TUNNELED DATA > ", sock->ssn->clean_out.data, sock->ssn->clean_out.used);
268
269         /*
270          *      If the packet is a complete RADIUS packet, return it to
271          *      the caller.  Otherwise...
272          */
273         if ((sock->ssn->clean_out.used < 20) ||
274             (((sock->ssn->clean_out.data[2] << 8) | sock->ssn->clean_out.data[3]) != (int) sock->ssn->clean_out.used)) {
275                 RDEBUG("Received bad packet: Length %d contents %d",
276                        sock->ssn->clean_out.used,
277                        (sock->ssn->clean_out.data[2] << 8) | sock->ssn->clean_out.data[3]);
278                 goto do_close;
279         }
280
281         packet = sock->packet;
282         packet->data = talloc_array(packet, uint8_t, sock->ssn->clean_out.used);
283         packet->data_len = sock->ssn->clean_out.used;
284         sock->ssn->record_minus(&sock->ssn->clean_out, packet->data, packet->data_len);
285         packet->vps = NULL;
286         PTHREAD_MUTEX_UNLOCK(&sock->mutex);
287
288         if (!rad_packet_ok(packet, 0, NULL)) {
289                 RDEBUG("Received bad packet: %s", fr_strerror());
290                 DEBUG("Closing TLS socket from client");
291                 PTHREAD_MUTEX_LOCK(&sock->mutex);
292                 tls_socket_close(listener);
293                 PTHREAD_MUTEX_UNLOCK(&sock->mutex);
294                 return 0;       /* do_close unlocks the mutex */
295         }
296
297         /*
298          *      Copied from src/lib/radius.c, rad_recv();
299          */
300         if (fr_debug_flag) {
301                 char host_ipaddr[128];
302
303                 if (is_radius_code(packet->code)) {
304                         RDEBUG("tls_recv: %s packet from host %s port %d, id=%d, length=%d",
305                                fr_packet_codes[packet->code],
306                                inet_ntop(packet->src_ipaddr.af,
307                                          &packet->src_ipaddr.ipaddr,
308                                          host_ipaddr, sizeof(host_ipaddr)),
309                                packet->src_port,
310                                packet->id, (int) packet->data_len);
311                 } else {
312                         RDEBUG("tls_recv: Packet from host %s port %d code=%d, id=%d, length=%d",
313                                inet_ntop(packet->src_ipaddr.af,
314                                          &packet->src_ipaddr.ipaddr,
315                                          host_ipaddr, sizeof(host_ipaddr)),
316                                packet->src_port,
317                                packet->code,
318                                packet->id, (int) packet->data_len);
319                 }
320         }
321
322         FR_STATS_INC(auth, total_requests);
323
324         return 1;
325 }
326
327
328 int dual_tls_recv(rad_listen_t *listener)
329 {
330         RADIUS_PACKET *packet;
331         REQUEST *request;
332         RAD_REQUEST_FUNP fun = NULL;
333         listen_socket_t *sock = listener->data;
334         RADCLIENT       *client = sock->client;
335
336         if (listener->status != RAD_LISTEN_STATUS_KNOWN) return 0;
337
338         if (!tls_socket_recv(listener)) {
339                 return 0;
340         }
341
342         rad_assert(sock->request != NULL);
343         rad_assert(sock->request->packet != NULL);
344         rad_assert(sock->packet != NULL);
345         rad_assert(sock->ssn != NULL);
346         rad_assert(client != NULL);
347
348         request = sock->request;
349         packet = sock->packet;
350
351         /*
352          *      Some sanity checks, based on the packet code.
353          *
354          *      "auth+acct" are marked as "auth", with the "dual" flag
355          *      set.
356          */
357         switch(packet->code) {
358         case PW_CODE_ACCESS_REQUEST:
359                 if (listener->type != RAD_LISTEN_AUTH) goto bad_packet;
360                 FR_STATS_INC(auth, total_requests);
361                 fun = rad_authenticate;
362                 break;
363
364 #ifdef WITH_ACCOUNTING
365         case PW_CODE_ACCOUNTING_REQUEST:
366                 if (listener->type != RAD_LISTEN_ACCT) {
367                         /*
368                          *      Allow auth + dual.  Disallow
369                          *      everything else.
370                          */
371                         if (!((listener->type == RAD_LISTEN_AUTH) &&
372                               (listener->dual))) {
373                                     goto bad_packet;
374                         }
375                 }
376                 FR_STATS_INC(acct, total_requests);
377                 fun = rad_accounting;
378                 break;
379 #endif
380
381         case PW_CODE_STATUS_SERVER:
382                 if (!main_config.status_server) {
383                         FR_STATS_INC(auth, total_unknown_types);
384                         WARN("Ignoring Status-Server request due to security configuration");
385                         rad_free(&sock->packet);
386                         request->packet = NULL;
387                         return 0;
388                 }
389                 fun = rad_status_server;
390                 break;
391
392         default:
393         bad_packet:
394                 FR_STATS_INC(auth, total_unknown_types);
395
396                 DEBUG("Invalid packet code %d sent from client %s port %d : IGNORED",
397                       packet->code, client->shortname, packet->src_port);
398                 rad_free(&sock->packet);
399                 request->packet = NULL;
400                 return 0;
401         } /* switch over packet types */
402
403         if (!request_receive(listener, packet, client, fun)) {
404                 FR_STATS_INC(auth, total_packets_dropped);
405                 rad_free(&sock->packet);
406                 request->packet = NULL;
407                 return 0;
408         }
409
410         sock->packet = NULL;    /* we have no need for more partial reads */
411         request->packet = NULL;
412
413         return 1;
414 }
415
416
417 /*
418  *      Send a response packet
419  */
420 int dual_tls_send(rad_listen_t *listener, REQUEST *request)
421 {
422         listen_socket_t *sock = listener->data;
423
424         VERIFY_REQUEST(request);
425
426         rad_assert(request->listener == listener);
427         rad_assert(listener->send == dual_tls_send);
428
429         if (listener->status != RAD_LISTEN_STATUS_KNOWN) return 0;
430
431         /*
432          *      Accounting reject's are silently dropped.
433          *
434          *      We do it here to avoid polluting the rest of the
435          *      code with this knowledge
436          */
437         if (request->reply->code == 0) return 0;
438
439         /*
440          *      Pack the VPs
441          */
442         if (rad_encode(request->reply, request->packet,
443                        request->client->secret) < 0) {
444                 RERROR("Failed encoding packet: %s", fr_strerror());
445                 return 0;
446         }
447
448         /*
449          *      Sign the packet.
450          */
451         if (rad_sign(request->reply, request->packet,
452                        request->client->secret) < 0) {
453                 RERROR("Failed signing packet: %s", fr_strerror());
454                 return 0;
455         }
456
457         PTHREAD_MUTEX_LOCK(&sock->mutex);
458
459         /*
460          *      Write the packet to the SSL buffers.
461          */
462         sock->ssn->record_plus(&sock->ssn->clean_in,
463                                request->reply->data, request->reply->data_len);
464
465         dump_hex("TUNNELED DATA < ", sock->ssn->clean_in.data, sock->ssn->clean_in.used);
466
467         /*
468          *      Do SSL magic to get encrypted data.
469          */
470         tls_handshake_send(request, sock->ssn);
471
472         /*
473          *      And finally write the data to the socket.
474          */
475         if (sock->ssn->dirty_out.used > 0) {
476                 dump_hex("WRITE TO SSL", sock->ssn->dirty_out.data, sock->ssn->dirty_out.used);
477
478                 tls_socket_write(listener, request);
479         }
480         PTHREAD_MUTEX_UNLOCK(&sock->mutex);
481
482         return 0;
483 }
484
485
486 #ifdef WITH_PROXY
487 /*
488  *      Read from the SSL socket.  Safe with either blocking or
489  *      non-blocking IO.  This level of complexity is probably not
490  *      necessary, as each packet gets put into one SSL application
491  *      record.  When SSL has a full record, we should be able to read
492  *      the entire packet via one SSL_read().
493  *
494  *      When SSL has a partial record, SSL_read() will return
495  *      WANT_READ or WANT_WRITE, and zero application data.
496  *
497  *      Called with the mutex held.
498  */
499 static ssize_t proxy_tls_read(rad_listen_t *listener)
500 {
501         int rcode;
502         size_t length;
503         uint8_t *data;
504         listen_socket_t *sock = listener->data;
505
506         /*
507          *      Get the maximum size of data to receive.
508          */
509         if (!sock->data) sock->data = talloc_array(sock, uint8_t,
510                                                    sock->ssn->offset);
511
512         data = sock->data;
513
514         if (sock->partial < 4) {
515                 rcode = SSL_read(sock->ssn->ssl, data + sock->partial,
516                                  4 - sock->partial);
517                 if (rcode <= 0) {
518                         int err = SSL_get_error(sock->ssn->ssl, rcode);
519                         switch (err) {
520                         case SSL_ERROR_WANT_READ:
521                         case SSL_ERROR_WANT_WRITE:
522                                 return 0; /* do some more work later */
523
524                         case SSL_ERROR_ZERO_RETURN:
525                                 /* remote end sent close_notify, send one back */
526                                 SSL_shutdown(sock->ssn->ssl);
527
528                         case SSL_ERROR_SYSCALL:
529                         do_close:
530                                 return -1;
531
532                         default:
533                                 while ((err = ERR_get_error())) {
534                                         DEBUG("proxy recv says %s",
535                                               ERR_error_string(err, NULL));
536                                 }
537
538                                 goto do_close;
539                         }
540                 }
541
542                 sock->partial = rcode;
543         } /* try reading the packet header */
544
545         if (sock->partial < 4) return 0; /* read more data */
546
547         length = (data[2] << 8) | data[3];
548
549         /*
550          *      Do these checks only once, when we read the header.
551          */
552         if (sock->partial == 4) {
553                 DEBUG3("Proxy received header saying we have a packet of %u bytes",
554                        (unsigned int) length);
555
556                 /*
557                  *      FIXME: allocate a RADIUS_PACKET, and set
558                  *      "data" to be as large as necessary.
559                  */
560                 if (length > sock->ssn->offset) {
561                         INFO("Received packet will be too large! Set \"fragment_size = %u\"",
562                              (data[2] << 8) | data[3]);
563                         goto do_close;
564                 }
565         }
566
567         /*
568          *      Try to read some more.
569          */
570         if (sock->partial < length) {
571                 rcode = SSL_read(sock->ssn->ssl, data + sock->partial,
572                                  length - sock->partial);
573                 if (rcode <= 0) {
574                         switch (SSL_get_error(sock->ssn->ssl, rcode)) {
575                         case SSL_ERROR_WANT_READ:
576                         case SSL_ERROR_WANT_WRITE:
577                                 return 0;
578
579                         case SSL_ERROR_ZERO_RETURN:
580                                 /* remote end sent close_notify, send one back */
581                                 SSL_shutdown(sock->ssn->ssl);
582                                 goto do_close;
583                         default:
584                                 goto do_close;
585                         }
586                 }
587
588                 sock->partial += rcode;
589         }
590
591         /*
592          *      If we're not done, say so.
593          *
594          *      Otherwise, reset the partially read data flag, and say
595          *      we have a packet.
596          */
597         if (sock->partial < length) {
598                 return 0;
599         }
600
601         sock->partial = 0;      /* we've now read the packet */
602         return length;
603 }
604
605
606 int proxy_tls_recv(rad_listen_t *listener)
607 {
608         listen_socket_t *sock = listener->data;
609         char buffer[256];
610         RADIUS_PACKET *packet;
611         uint8_t *data;
612         ssize_t data_len;
613
614         if (listener->status != RAD_LISTEN_STATUS_KNOWN) return 0;
615
616         DEBUG3("Proxy SSL socket has data to read");
617         PTHREAD_MUTEX_LOCK(&sock->mutex);
618         data_len = proxy_tls_read(listener);
619         PTHREAD_MUTEX_UNLOCK(&sock->mutex);
620
621         if (data_len < 0) {
622                 DEBUG("Closing TLS socket to home server");
623                 PTHREAD_MUTEX_LOCK(&sock->mutex);
624                 tls_socket_close(listener);
625                 PTHREAD_MUTEX_UNLOCK(&sock->mutex);
626                 return 0;
627         }
628
629         if (data_len == 0) return 0; /* not done yet */
630
631         data = sock->data;
632
633         packet = rad_alloc(sock, false);
634         packet->sockfd = listener->fd;
635         packet->src_ipaddr = sock->other_ipaddr;
636         packet->src_port = sock->other_port;
637         packet->dst_ipaddr = sock->my_ipaddr;
638         packet->dst_port = sock->my_port;
639         packet->code = data[0];
640         packet->id = data[1];
641         packet->data_len = data_len;
642         packet->data = talloc_array(packet, uint8_t, packet->data_len);
643         memcpy(packet->data, data, packet->data_len);
644         memcpy(packet->vector, packet->data + 4, 16);
645
646         /*
647          *      FIXME: Client MIB updates?
648          */
649         switch(packet->code) {
650         case PW_CODE_ACCESS_ACCEPT:
651         case PW_CODE_ACCESS_CHALLENGE:
652         case PW_CODE_ACCESS_REJECT:
653                 break;
654
655 #ifdef WITH_ACCOUNTING
656         case PW_CODE_ACCOUNTING_RESPONSE:
657                 break;
658 #endif
659
660         default:
661                 /*
662                  *      FIXME: Update MIB for packet types?
663                  */
664                 ERROR("Invalid packet code %d sent to a proxy port "
665                        "from home server %s port %d - ID %d : IGNORED",
666                        packet->code,
667                        ip_ntoh(&packet->src_ipaddr, buffer, sizeof(buffer)),
668                        packet->src_port, packet->id);
669                 rad_free(&packet);
670                 return 0;
671         }
672
673         if (!request_proxy_reply(packet)) {
674                 rad_free(&packet);
675                 return 0;
676         }
677
678         return 1;
679 }
680
681
682 int proxy_tls_send(rad_listen_t *listener, REQUEST *request)
683 {
684         int rcode;
685         listen_socket_t *sock = listener->data;
686
687         VERIFY_REQUEST(request);
688
689         if ((listener->status != RAD_LISTEN_STATUS_INIT) &&
690             (listener->status != RAD_LISTEN_STATUS_KNOWN)) return 0;
691
692         /*
693          *      Normal proxying calls us with the data already
694          *      encoded.  The "ping home server" code does not.  So,
695          *      if there's no packet, encode it here.
696          */
697         if (!request->proxy->data) {
698                 request->proxy_listener->encode(request->proxy_listener,
699                                                 request);
700         }
701
702         DEBUG3("Proxy is writing %u bytes to SSL",
703                (unsigned int) request->proxy->data_len);
704         PTHREAD_MUTEX_LOCK(&sock->mutex);
705         rcode = SSL_write(sock->ssn->ssl, request->proxy->data,
706                           request->proxy->data_len);
707         if (rcode < 0) {
708                 int err;
709
710                 err = ERR_get_error();
711                 switch (err) {
712                 case SSL_ERROR_NONE:
713                 case SSL_ERROR_WANT_READ:
714                 case SSL_ERROR_WANT_WRITE:
715                         break;  /* let someone else retry */
716
717                 default:
718                         DEBUG("proxy SSL_write says %s",
719                               ERR_error_string(err, NULL));
720                         DEBUG("Closing TLS socket to home server");
721                         tls_socket_close(listener);
722                         PTHREAD_MUTEX_UNLOCK(&sock->mutex);
723                         return 0;
724                 }
725         }
726         PTHREAD_MUTEX_UNLOCK(&sock->mutex);
727
728         return 1;
729 }
730 #endif  /* WITH_PROXY */
731
732 #endif  /* WITH_TLS */