~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Nginx/event/ngx_event_openssl.h

Version: ~ [ nginx-0.6.26 ] ~ [ nginx-0.5.35 ] ~ [ nginx-0.5.20 ] ~ [ nginx-0.5.19 ] ~

  1 
  2 /*
  3  * Copyright (C) Igor Sysoev
  4  */
  5 
  6 
  7 #ifndef _NGX_EVENT_OPENSSL_H_INCLUDED_
  8 #define _NGX_EVENT_OPENSSL_H_INCLUDED_
  9 
 10 
 11 #include <ngx_config.h>
 12 #include <ngx_core.h>
 13 
 14 #include <openssl/ssl.h>
 15 #include <openssl/err.h>
 16 
 17 #if OPENSSL_VERSION_NUMBER >= 0x00907000
 18 #include <openssl/conf.h>
 19 #include <openssl/engine.h>
 20 #define NGX_SSL_ENGINE   1
 21 #endif
 22 
 23 #define NGX_SSL_NAME     "OpenSSL"
 24 
 25 
 26 #define ngx_ssl_session_t       SSL_SESSION
 27 #define ngx_ssl_conn_t          SSL
 28 
 29 
 30 typedef struct {
 31     SSL_CTX                    *ctx;
 32     ngx_log_t                  *log;
 33 } ngx_ssl_t;
 34 
 35 
 36 typedef struct {
 37     ngx_ssl_conn_t             *connection;
 38 
 39     ngx_int_t                   last;
 40     ngx_buf_t                  *buf;
 41 
 42     ngx_connection_handler_pt   handler;
 43 
 44     ngx_event_handler_pt        saved_read_handler;
 45     ngx_event_handler_pt        saved_write_handler;
 46 
 47     unsigned                    handshaked:1;
 48     unsigned                    buffer:1;
 49     unsigned                    no_wait_shutdown:1;
 50     unsigned                    no_send_shutdown:1;
 51 } ngx_ssl_connection_t;
 52 
 53 
 54 #define NGX_SSL_DFLT_BUILTIN_SCACHE  -2
 55 #define NGX_SSL_NO_BUILTIN_SCACHE    -3
 56 #define NGX_SSL_NO_SCACHE            -4
 57 
 58 
 59 #define NGX_SSL_MAX_SESSION_SIZE  4096
 60 
 61 typedef struct ngx_ssl_sess_id_s  ngx_ssl_sess_id_t;
 62 
 63 struct ngx_ssl_sess_id_s {
 64     ngx_rbtree_node_t           node;
 65     u_char                     *id;
 66     size_t                      len;
 67     u_char                     *session;
 68     ngx_queue_t                 queue;
 69     time_t                      expire;
 70 #if (NGX_PTR_SIZE == 8)
 71     void                       *stub;
 72     u_char                      sess_id[32];
 73 #endif
 74 };
 75 
 76 
 77 typedef struct {
 78     ngx_rbtree_t                session_rbtree;
 79     ngx_rbtree_node_t           sentinel;
 80     ngx_queue_t                 expire_queue;
 81 } ngx_ssl_session_cache_t;
 82 
 83 
 84 
 85 #define NGX_SSL_SSLv2    2
 86 #define NGX_SSL_SSLv3    4
 87 #define NGX_SSL_TLSv1    8
 88 
 89 
 90 #define NGX_SSL_BUFFER   1
 91 #define NGX_SSL_CLIENT   2
 92 
 93 #define NGX_SSL_BUFSIZE  16384
 94 
 95 
 96 ngx_int_t ngx_ssl_init(ngx_log_t *log);
 97 ngx_int_t ngx_ssl_create(ngx_ssl_t *ssl, ngx_uint_t protocols, void *data);
 98 ngx_int_t ngx_ssl_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl,
 99     ngx_str_t *cert, ngx_str_t *key);
100 ngx_int_t ngx_ssl_client_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl,
101     ngx_str_t *cert, ngx_int_t depth);
102 ngx_int_t ngx_ssl_generate_rsa512_key(ngx_ssl_t *ssl);
103 ngx_int_t ngx_ssl_session_cache(ngx_ssl_t *ssl, ngx_str_t *sess_ctx,
104     ssize_t builtin_session_cache, ngx_shm_zone_t *shm_zone, time_t timeout);
105 ngx_int_t ngx_ssl_create_connection(ngx_ssl_t *ssl, ngx_connection_t *c,
106     ngx_uint_t flags);
107 
108 ngx_int_t ngx_ssl_set_session(ngx_connection_t *c, ngx_ssl_session_t *session);
109 #define ngx_ssl_get_session(c)      SSL_get1_session(c->ssl->connection)
110 #define ngx_ssl_free_session        SSL_SESSION_free
111 #define ngx_ssl_get_connection(ssl_conn)                                      \
112     SSL_get_ex_data(ssl_conn, ngx_ssl_connection_index)
113 #define ngx_ssl_get_server_conf(ssl_ctx)                                      \
114     SSL_CTX_get_ex_data(ssl_ctx, ngx_ssl_server_conf_index)
115 
116 
117 ngx_int_t ngx_ssl_get_protocol(ngx_connection_t *c, ngx_pool_t *pool,
118     ngx_str_t *s);
119 ngx_int_t ngx_ssl_get_cipher_name(ngx_connection_t *c, ngx_pool_t *pool,
120     ngx_str_t *s);
121 ngx_int_t ngx_ssl_get_subject_dn(ngx_connection_t *c, ngx_pool_t *pool,
122     ngx_str_t *s);
123 ngx_int_t ngx_ssl_get_issuer_dn(ngx_connection_t *c, ngx_pool_t *pool,
124     ngx_str_t *s);
125 ngx_int_t ngx_ssl_get_serial_number(ngx_connection_t *c, ngx_pool_t *pool,
126     ngx_str_t *s);
127 
128 
129 ngx_int_t ngx_ssl_handshake(ngx_connection_t *c);
130 ssize_t ngx_ssl_recv(ngx_connection_t *c, u_char *buf, size_t size);
131 ssize_t ngx_ssl_write(ngx_connection_t *c, u_char *data, size_t size);
132 ssize_t ngx_ssl_recv_chain(ngx_connection_t *c, ngx_chain_t *cl);
133 ngx_chain_t *ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in,
134     off_t limit);
135 void ngx_ssl_free_buffer(ngx_connection_t *c);
136 ngx_int_t ngx_ssl_shutdown(ngx_connection_t *c);
137 void ngx_cdecl ngx_ssl_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
138     char *fmt, ...);
139 void ngx_ssl_cleanup_ctx(void *data);
140 
141 
142 extern int  ngx_ssl_connection_index;
143 extern int  ngx_ssl_server_conf_index;
144 extern int  ngx_ssl_session_cache_index;
145 
146 
147 #endif /* _NGX_EVENT_OPENSSL_H_INCLUDED_ */
148 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.