ssl.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C), 2000-2002 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 #ifdef HAVE_OPENSSL
00034 typedef struct my_ssl_connection {
00035 
00036   int           socket;
00037   int           accepted;
00038 
00039   SSL*          handler;
00040   SSL_CTX *     ctx;
00041   X509 *        cert;
00042   SSL_METHOD *  method;
00043   BIO *         socket_bio;
00044 
00045   const char *  cipher;
00046 
00047   char *        cert_subject;
00048   char *        cert_issuer;
00049   unsigned char * cert_md5;
00050   unsigned int  cert_md5_len;
00051 
00052   char          * clientpemfile;
00053 
00054   struct my_ssl_connection *prev;
00055   struct my_ssl_connection *next;
00056   
00057 } ssl_connection;
00058 
00059 
00060 typedef struct my_ssl_server_connection {
00061 
00062   int           server_socket;
00063 
00064   SSL_METHOD *  method;
00065   SSL_CTX *     ctx;
00066 
00067   char          * pemfile;
00068   char          * clientpemfile;
00069 
00070 
00071   ssl_connection *ssl_conn_list;
00072   
00073 } ssl_server_connection;
00074 #else
00075 
00076 typedef  void ssl_connection;
00077 typedef  void ssl_server_connection;
00078 
00079 #endif
00080 
00081 
00082 ssl_connection * new_ssl_connection(char *);
00083 ssl_server_connection * new_ssl_server_connection(char *, char *);
00084 
00085 ssl_connection * create_ssl_socket(char *, int, int);
00086 int embed_ssl_socket (ssl_connection *, int);
00087 
00088 ssl_server_connection * init_ssl_server (char *, char *);
00089 ssl_server_connection * create_ssl_server_socket(char *, int, int, char *, char *);
00090 int embed_accepted_ssl_socket(ssl_connection *, int);
00091 ssl_connection *  accept_ssl_socket(ssl_server_connection *);
00092 
00093 ssl_connection * insert_accepted_ssl_socket (ssl_server_connection *);
00094 
00095 int close_ssl_socket(ssl_connection *);
00096 int close_ssl_server_socket(ssl_server_connection *);
00097 int close_accepted_ssl_socket(ssl_server_connection *, ssl_connection *);
00098 
00099 int cleanup_ssl_socket(ssl_connection *);
00100 int cleanup_ssl_server_socket(ssl_server_connection *);
00101 
00102 int delete_ssl_socket(ssl_connection *);
00103 int delete_ssl_server_socket(ssl_server_connection *);
00104 int delete_accepted_ssl_socket (ssl_server_connection *, ssl_connection *);
00105 
00106 int update_ssl_cert_data(ssl_connection *);
00107 int check_ssl_md5sum(ssl_connection * , char *);
00108 
00109 int send_ssl_socket(ssl_connection *, void *, int);
00110 int recv_ssl_socket(ssl_connection *, void *, int);
00111 char * gets_ssl_socket(ssl_connection *, char *, int);
00112 int printf_ssl_socket(ssl_connection *, const char *, ...);
00113 
00114 int start_ssl(void);
00115 int stop_ssl(void);
00116 void config_ssl(int);
00117 
00118 int have_ssl(void);
00119 
00120 #endif