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