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