ffead.server.doc
SSLClient.h
1 /*
2  Copyright 2010, Sumeet Chhetri
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 /*
17  * SSLClient.h
18  *
19  * Created on: Dec 14, 2010
20  * Author: sumeet
21  */
22 
23 #ifndef SSLCLIENT_H_
24 #define SSLCLIENT_H_
25 #include "ClientInterface.h"
26 using namespace std;
27 #define KEYFILE "client.pem"
28 #define PASSWORD "password"
29 #define DHFILE "dh1024.pem"
30 #define CA_LIST "root.pem"
31 
32 class SSLClient : public ClientInterface {
33  SSL *ssl;
34  SSL_CTX *ctx;
35  BIO *sbio,*io,*ssl_bio;
36  int sockfd;
37  bool connected;
38  void *get_in_addr1(struct sockaddr *sa);
39  SSL_CTX *initialize_ctx(char *keyfile,char *password);
40  void destroy_ctx(SSL_CTX *ctx);
41  void error_occurred(char *error);
42  void closeSSL();
43  Logger logger;
44 public:
45  SSLClient();
46  virtual ~SSLClient();
47  bool connection(string,int);
48  bool connectionUnresolv(string host,int port);
49  int sendData(string);
50  string getData(string hdrdelm,string cntlnhdr);
51  string getData(int cntlen);
52  void closeConnection();
53  bool isConnected();
54  string getBinaryData(int,bool);
55  string getTextData(string hdrdelm,string cntlnhdr);
56 };
57 
58 #endif /* SSLCLIENT_H_ */