ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/Search/HttpHandler.cpp
(Generate patch)

Comparing trunk/Search/HttpHandler.cpp (file contents):
Revision 210 by douglas, 2003-07-18T00:26:41-07:00 vs.
Revision 211 by douglas, 2003-07-19T18:46:12-07:00

# Line 46 | Line 46
46   //
47   // Douglas Thrift
48   //
49 < // $Id: HttpHandler.cpp,v 1.21 2003/07/18 07:26:41 douglas Exp $
49 > // $Id: HttpHandler.cpp,v 1.22 2003/07/20 01:46:12 douglas Exp $
50  
51   #include "HttpHandler.h"
52  
# Line 58 | Line 58
58   #include <sys/socket.h>
59   #include <netinet/in.h>
60   #include <netdb.h>
61
62 #define INVALID_SOCKET -1
63 #define SOCKET_ERROR -1
64
65 inline int closesocket(SOCKET s) { return close(s); }
61   #endif
62  
63   HttpHandler::HttpHandler()
# Line 761 | Line 756 | bool HttpHandler::starttls()
756          SSL_load_error_strings();
757          SSL_library_init();
758  
759 <        //
759 > #ifndef _urandomdev_
760 >        int pid = getpid();
761 >        int now = time(NULL);
762 >
763 >        unsigned seed = now > pid ? now - pid : pid - now;
764 >
765 >        char* junk = new char[seed % 30 + 2];
766 >        junk[0] = pid;
767 >        junk[seed % 30 + 1] = now;
768 >
769 >        srand(seed);
770 >
771 >        for (int index = 1; index < seed % 30 + 1; index++)
772 >        {
773 >                junk[index] = rand();
774 >        }
775 >
776 >        if (debug)
777 >        {
778 >                cerr << "junk = {\n";
779 >
780 >                for (int index = 1; index < seed % 30 + 2; index++)
781 >                {
782 >                        cerr << "   [" << index << "] = " << int(junk[index]) << "\n";
783 >                }
784 >
785 >                cerr << "}\n";
786 >        }
787 >
788 >        RAND_seed(junk, seed % 30 + 2);
789 >
790 >        delete junk;
791 > #endif
792 >
793 >        ctx = SSL_CTX_new(TLSv1_client_method());
794 >
795 >        if (ctx == NULL)
796 >        {
797 >                cerr << program << ": SSL CTX New: "
798 >                        << ERR_reason_error_string(ERR_get_error()) << "\n";
799 >                return false;
800 >        }
801 >
802 >        ssl = SSL_new(ctx);
803 >
804 >        if (SSL_set_fd(ssl, http) == 0)
805 >        {
806 >                cerr << program << ": SSL Set FD: "
807 >                        << ERR_reason_error_string(ERR_get_error()) << "\n";
808 >                return false;
809 >        }
810 >
811 >        int number;
812 >
813 >        if ((number = SSL_connect(ssl)) <= 0)
814 >        {
815 >                error(program + ": SSL Connect", number);
816 >                return false;
817 >        }
818  
819          return true;
820   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines