ssl.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C), 2000-2003 by Contributors to the monit codebase. 
00003  * All Rights Reserved.
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License as
00007  * published by the Free Software Foundation; either version 2 of the
00008  * License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software Foundation,
00017  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00018  */
00019 
00020 #ifndef SSL_H
00021 #define SSL_H
00022 
00023 #include <config.h>
00024 
00025 #ifdef HAVE_OPENSSL
00026 #include <openssl/crypto.h>
00027 #include <openssl/x509.h>
00028 #include <openssl/pem.h>
00029 #include <openssl/ssl.h>
00030 #include <openssl/err.h>
00031 #endif
00032 
00033 #define SSL_VERSION_AUTO       0
00034 #define SSL_VERSION_SSLV2      1
00035 #define SSL_VERSION_SSLV3      2
00036 #define SSL_VERSION_TLS        3
00037 
00038 #ifdef HAVE_OPENSSL
00039 typedef struct my_ssl_connection {
00040 
00041   int           socket;
00042   int           accepted;
00043 
00044   SSL*          handler;
00045   SSL_CTX *     ctx;
00046   X509 *        cert;
00047   SSL_METHOD *  method;
00048   BIO *         socket_bio;
00049 
00050   const char *  cipher;
00051 
00052   char *        cert_subject;
00053   char *        cert_issuer;
00054   unsigned char * cert_md5;
00055   unsigned int  cert_md5_len;
00056 
00057   char          * clientpemfile;
00058 
00059   struct my_ssl_connection *prev;
00060   struct my_ssl_connection *next;
00061   
00062 } ssl_connection;
00063 
00064 
00065 typedef struct my_ssl_server_connection {
00066 
00067   int           server_socket;
00068 
00069   SSL_METHOD *  method;
00070   SSL_CTX *     ctx;
00071 
00072   char          * pemfile;
00073   char          * clientpemfile;
00074 
00075 
00076   ssl_connection *ssl_conn_list;
00077   
00078 } ssl_server_connection;
00079 
00080 #else
00081 
00082 typedef  void ssl_connection;
00083 typedef  void ssl_server_connection;
00084 
00085 #endif
00086 
00087 
00088 ssl_connection * new_ssl_connection(char *, int);
00089 ssl_server_connection * new_ssl_server_connection(char *, char *);
00090 
00091 ssl_connection * create_ssl_socket(char *, int, int, int);
00092 int embed_ssl_socket (ssl_connection *, int);
00093 
00094 ssl_server_connection * init_ssl_server (char *, char *);
00095 ssl_server_connection * create_ssl_server_socket(char *, int, int, char *, char *);
00096 int embed_accepted_ssl_socket(ssl_connection *, int);
00097 ssl_connection *  accept_ssl_socket(ssl_server_connection *);
00098 
00099 ssl_connection * insert_accepted_ssl_socket (ssl_server_connection *);
00100 
00101 int close_ssl_socket(ssl_connection *);
00102 int close_ssl_server_socket(ssl_server_connection *);
00103 int close_accepted_ssl_socket(ssl_server_connection *, ssl_connection *);
00104 
00105 int cleanup_ssl_socket(ssl_connection *);
00106 int cleanup_ssl_server_socket(ssl_server_connection *);
00107 
00108 int delete_ssl_socket(ssl_connection *);
00109 int delete_ssl_server_socket(ssl_server_connection *);
00110 int delete_accepted_ssl_socket (ssl_server_connection *, ssl_connection *);
00111 
00112 int update_ssl_cert_data(ssl_connection *);
00113 int check_ssl_md5sum(ssl_connection * , char *);
00114 
00115 int send_ssl_socket(ssl_connection *, void *, int);
00116 int recv_ssl_socket(ssl_connection *, void *, int);
00117 char * gets_ssl_socket(ssl_connection *, char *, int);
00118 int printf_ssl_socket(ssl_connection *, const char *, ...);
00119 
00120 int start_ssl(void);
00121 int stop_ssl(void);
00122 void config_ssl(int);
00123 
00124 int have_ssl(void);
00125 
00126 #endif