| 1 |
/* |
| 2 |
SSL interface definitions internal to neon. |
| 3 |
Copyright (C) 2003-2005, 2008, 2009, Joe Orton <[email protected]> |
| 4 |
Copyright (C) 2004, Aleix Conchillo Flaque <[email protected]> |
| 5 |
|
| 6 |
This library is free software; you can redistribute it and/or |
| 7 |
modify it under the terms of the GNU Library General Public |
| 8 |
License as published by the Free Software Foundation; either |
| 9 |
version 2 of the License, or (at your option) any later version. |
| 10 |
|
| 11 |
This library is distributed in the hope that it will be useful, |
| 12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
Library General Public License for more details. |
| 15 |
|
| 16 |
You should have received a copy of the GNU Library General Public |
| 17 |
License along with this library; if not, write to the Free |
| 18 |
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
| 19 |
MA 02111-1307, USA |
| 20 |
|
| 21 |
*/ |
| 22 |
|
| 23 |
/* THIS IS NOT A PUBLIC INTERFACE. You CANNOT include this header file |
| 24 |
* from an application. */ |
| 25 |
|
| 26 |
#ifndef NE_PRIVSSL_H |
| 27 |
#define NE_PRIVSSL_H |
| 28 |
|
| 29 |
/* This is the private interface between ne_socket, ne_gnutls and |
| 30 |
* ne_openssl. */ |
| 31 |
|
| 32 |
#include "ne_ssl.h" |
| 33 |
#include "ne_socket.h" |
| 34 |
|
| 35 |
#ifdef HAVE_OPENSSL |
| 36 |
|
| 37 |
#include <openssl/ssl.h> |
| 38 |
|
| 39 |
struct ne_ssl_context_s { |
| 40 |
SSL_CTX *ctx; |
| 41 |
SSL_SESSION *sess; |
| 42 |
const char *hostname; /* for SNI */ |
| 43 |
int failures; /* bitmask of exposed failure bits. */ |
| 44 |
short added_chain; |
| 45 |
}; |
| 46 |
|
| 47 |
typedef SSL *ne_ssl_socket; |
| 48 |
|
| 49 |
/* Create a clicert object from cert DER {der, der_len}, using given |
| 50 |
* RSA_METHOD for the RSA object. */ |
| 51 |
NE_PRIVATE ne_ssl_client_cert * |
| 52 |
ne__ssl_clicert_exkey_import(const unsigned char *der, |
| 53 |
size_t der_len, |
| 54 |
const RSA_METHOD *method); |
| 55 |
|
| 56 |
#endif /* HAVE_OPENSSL */ |
| 57 |
|
| 58 |
#ifdef HAVE_GNUTLS |
| 59 |
|
| 60 |
#include <gnutls/gnutls.h> |
| 61 |
|
| 62 |
struct ne_ssl_context_s { |
| 63 |
gnutls_certificate_credentials cred; |
| 64 |
int verify; /* non-zero if client cert verification required */ |
| 65 |
|
| 66 |
const char *hostname; /* for SNI */ |
| 67 |
|
| 68 |
/* Session cache. */ |
| 69 |
union ne_ssl_scache { |
| 70 |
struct { |
| 71 |
gnutls_datum key, data; |
| 72 |
} server; |
| 73 |
#if defined(HAVE_GNUTLS_SESSION_GET_DATA2) |
| 74 |
gnutls_datum client; |
| 75 |
#else |
| 76 |
struct { |
| 77 |
char *data; |
| 78 |
size_t len; |
| 79 |
} client; |
| 80 |
#endif |
| 81 |
} cache; |
| 82 |
|
| 83 |
#ifdef HAVE_GNUTLS_SIGN_CALLBACK_SET |
| 84 |
gnutls_sign_func sign_func; |
| 85 |
void *sign_data; |
| 86 |
#endif |
| 87 |
}; |
| 88 |
|
| 89 |
typedef gnutls_session ne_ssl_socket; |
| 90 |
|
| 91 |
NE_PRIVATE ne_ssl_client_cert * |
| 92 |
ne__ssl_clicert_exkey_import(const unsigned char *der, size_t der_len); |
| 93 |
|
| 94 |
#endif /* HAVE_GNUTLS */ |
| 95 |
|
| 96 |
#ifdef NE_HAVE_SSL |
| 97 |
NE_PRIVATE ne_ssl_socket ne__sock_sslsock(ne_socket *sock); |
| 98 |
|
| 99 |
/* Process-global initialization of the SSL library; returns non-zero |
| 100 |
* on error. */ |
| 101 |
NE_PRIVATE int ne__ssl_init(void); |
| 102 |
|
| 103 |
/* Process-global de-initialization of the SSL library. */ |
| 104 |
NE_PRIVATE void ne__ssl_exit(void); |
| 105 |
#endif |
| 106 |
|
| 107 |
#endif /* NE_PRIVSSL_H */ |