ffead.server.doc
SSLHandler.h
1 /*
2  Copyright 2009-2012, 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  * SSLHandler.h
18  *
19  * Created on: 20-Jun-2012
20  * Author: sumeetc
21  */
22 
23 #ifndef SSLHANDLER_H_
24 #define SSLHANDLER_H_
25 #include <string>
26 #include <sys/socket.h>
27 #include <iostream>
28 /*HTTPS related*/
29 #include <openssl/ssl.h>
30 #include <signal.h>
31 #include "Logger.h"
32 #define CLIENT_AUTH_REQUEST 1
33 #define CLIENT_AUTH_REQUIRE 2
34 #define CLIENT_AUTH_REHANDSHAKE 3
35 
36 using namespace std;
37 
38 class SSLHandler {
39  static char *pass;
40  static BIO *bio_err;
41  static Logger logger;
42 public:
43  static int s_server_session_id_context;
44  static int s_server_auth_session_id_context;
45  SSLHandler();
46  virtual ~SSLHandler();
47  static int password_cb(char *buf,int num, int rwflag,void *userdata);
48  void load_dh_params(SSL_CTX *ctx,char *file);
49  static void sigpipe_handle(int x);
50  SSL_CTX *initialize_ctx(char *keyfile,char *password, string ca_list);
51  void destroy_ctx(SSL_CTX *ctx);
52  void error_occurred(char *error,int fd,SSL *ssl);
53  void closeSSL(int fd,SSL *ssl,BIO* bio);
54 };
55 
56 #endif /* SSLHANDLER_H_ */