   SSL(secure sockets layer) help!
  I''m triyng to create my own ssl lib with c++. I am trying to communicate with nexus.passport.com:443 but after I send a client_hello my connection ends abruptly. I''m sending my client hello structure inside a handshake structure which is at the same time inside a SSLPlainText structure, I dont know if I''m missing something. Please help me, thanksDiego Mendieta.here is some of my code:struct ClientHello {ProtocolVersion client_version;Random random;uint32 session_id;uint8 cipher_suites[2];//{ 0x00,0x01 };uint8 compression_methods;//0};struct Handshake {uint8 msg_type;uint8 lenth[3];ClientHello var;};struct SSLPlainText {uint8 type;ProtocolVersion version;uint16 lenth;Handshake fragment;};Remember this only for the client hello, I''m only trying to see if I understand the concept of ssl, and if I can send the first message and get an asnwer.  The problem is that I cannot even do that, please help me. 
  I suggest installing Apache with SSL on your own machine, and talking to that until you can do that flawlessly.Ideally, install Apache with source (or build it yourself!) so that you can debug it while connecting, and figure out what it doesn''t like.Or just use openssl, which has done all the development or debugging for you. Free of charge! ;  Unless you are looking for a sequence diagram on how this can be done, I would recommend that you post your question to the following forum:http://www.gamedev.net/community/forums/forum.asp?forum_id=21;  Be sure to disable structure padding via #pragma directives if you are planning on casting the structures to char* when you send them. ;quote:Original post by Anonymous Poster   Unless you are looking for a sequence diagram on how this can be done, I would recommend that you post your question to the following forum:http://www.gamedev.net/community/forums/forum.asp?forum_id=21 I concur, except I think 15 is most appropriate.   [edited by - Magmai Kai Holmlor on November 11, 2003 12:28:53 PM];quote:Original post by antareus  Be sure to disable structure padding via #pragma directives if you are planning on casting the structures to char* when you send them.   I would definetly agree, looks like another case of MSVC''s structure padding.  Please add this to your code //First line to add#pragma pack(1) //Tells MSVC to pack structs to 1 byte alignements rather than the default 4struct ClientHello {ProtocolVersion client_version;Random random;uint32 session_id;uint8 cipher_suites[2];//{ 0x00,0x01 };uint8 compression_methods;//0};struct Handshake {uint8 msg_type;uint8 lenth[3];ClientHello var;};struct SSLPlainText {uint8 type;ProtocolVersion version;uint16 lenth;Handshake fragment; };//Second line to add after your structs are defined#pragma pack() //Tells MSVC to use it''s default packing method (4 bytes).;  I added the pragma and I still get diconected, there has to be another error.  Please help me, thxDiego Mendieta ;  I dont know what my problem could be, but maybe my problem is in the data inside the structure, here is the initial data, remember its only a try and many things are should only work for the first messeage(hello_client):client_hello.client_version.major=3;client_hello.client_version.minor=0;client_hello.random.gmt_unix_time=0;client_hello.random.random_bytes[0]=''q'';client_hello.random.random_bytes[1]=''w'';client_hello.random.random_bytes[2]=''g'';client_hello.random.random_bytes[3]=''g'';client_hello.random.random_bytes[4]=''h'';client_hello.random.random_bytes[5]=''y'';client_hello.random.random_bytes[6]=''i'';client_hello.random.random_bytes[7]=''7'';client_hello.random.random_bytes[8]=''t'';client_hello.random.random_bytes[9]=''d'';client_hello.random.random_bytes[10]=''g'';client_hello.random.random_bytes[11]=''g'';client_hello.random.random_bytes[12]=''y'';client_hello.random.random_bytes[13]=''o''; client_hello.random.random_bytes[14]=''p'';client_hello.random.random_bytes[15]=''2'';client_hello.random.random_bytes[16]=''x'';client_hello.random.random_bytes[17]=''d'';client_hello.random.random_bytes[18]=''t'';client_hello.random.random_bytes[19]=''h'';client_hello.random.random_bytes[20]=''j'';client_hello.random.random_bytes[21]=''i'';client_hello.random.random_bytes[22]=''7'';client_hello.random.random_bytes[23]=''e'';client_hello.random.random_bytes[24]=''s'';client_hello.random.random_bytes[25]=''c'';client_hello.random.random_bytes[26]=''f'';client_hello.random.random_bytes[27]=''6'';client_hello.random.random_bytes[28]=''y'';client_hello.random.random_bytes[29]=''u'';client_hello.random.random_bytes[30]=''i'';client_hello.random.random_bytes[31]=''5'';client_hello.compression_methods=0;client_hello.session_id=0;client_hello.cipher_suites[0]=0x00;client_hello.cipher_suites[1]=0x01;Handshake hs;int a = sizeof(client_hello);hs.lenth[0]=(char )0x00;hs.lenth[1]=(char )0x00;hs.lenth[2]=(char )0x30;hs.msg_type=1;//clienthello;hs.var=client_hello;int size=sizeof(hs);pack1.type=22;//handshake;pack1.version.major=3;pack1.version.minor=0;pack1.lenth=size;pack1.fragment=hs;connect_to_server();send(Socket,(char *)&pack1,sizeof(pack1),0);recv(Socket,buffer,1023,0);//here I recieve an empty string, and I''m disconnected from server. ;  Hold on, you''re sending random gibberish to an SSL server and complaining about being disconnected?Neither do I see any encryption information in your code, so it looks like you''re sending garbage and the server responds appriopriately. ;  ?I''m not sending garbage, I''m sending the client_hello structure,this is inside a handshake structure, which is inside a packege, its not garbage.  The info is wrong, that''s why I get disconected, but it is nos garbage. 