Lines 1-27
Link Here
|
1 |
--- lib/ssl.c.orig 2012-06-30 14:30:08 UTC |
1 |
--- lib/ssl.c.orig 2012-06-30 14:30:08 UTC |
2 |
+++ lib/ssl.c |
2 |
+++ lib/ssl.c |
3 |
@@ -78,6 +78,7 @@ static void os_initialize_prng(struct ss |
3 |
@@ -14,6 +14,7 @@ |
|
|
4 |
/* Headers files for OpenSSL */ |
5 |
|
6 |
#include <openssl/lhash.h> |
7 |
+#include <openssl/opensslv.h> |
8 |
#include <openssl/ssl.h> |
9 |
#include <openssl/err.h> |
10 |
#include <openssl/rand.h> |
11 |
@@ -78,17 +79,6 @@ static void os_initialize_prng(struct ssl_config *ssl_ |
4 |
int totbytes = 0; |
12 |
int totbytes = 0; |
5 |
int bytes; |
13 |
int bytes; |
6 |
|
14 |
|
7 |
+#ifndef OPENSSL_NO_EGD |
15 |
- if (ssl_config->egd_socket) { |
8 |
if (ssl_config->egd_socket) { |
16 |
- if ((bytes = RAND_egd(ssl_config->egd_socket)) == -1) { |
9 |
if ((bytes = RAND_egd(ssl_config->egd_socket)) == -1) { |
17 |
- log_fatal("EGD Socket %s failed", ssl_config->egd_socket); |
10 |
log_fatal("EGD Socket %s failed", ssl_config->egd_socket); |
18 |
- } else { |
11 |
@@ -88,6 +89,7 @@ static void os_initialize_prng(struct ss |
19 |
- totbytes += bytes; |
12 |
goto SEEDED; /* ditto */ |
20 |
- log_debug("Snagged %d random bytes from EGD Socket %s", |
|
|
21 |
- bytes, ssl_config->egd_socket); |
22 |
- goto SEEDED; /* ditto */ |
23 |
- } |
24 |
- } |
25 |
- |
26 |
/* Try the good-old default /dev/urandom, if available */ |
27 |
totbytes += add_rand_file("/dev/urandom"); |
28 |
if (prng_seeded(totbytes)) { |
29 |
@@ -212,6 +202,8 @@ static int new_session_cb(SSL * ssl, SSL_SESSION * ses |
30 |
unsigned char *data = NULL, *asn; |
31 |
time_t expire; |
32 |
int ret = -1; |
33 |
+ unsigned int session_id_length; |
34 |
+ unsigned char *session_id = SSL_SESSION_get_id(sess, &session_id_length); |
35 |
|
36 |
if (!sess_dbopen) |
37 |
return 0; |
38 |
@@ -241,8 +233,7 @@ static int new_session_cb(SSL * ssl, SSL_SESSION * ses |
39 |
if (data && len) { |
40 |
/* store the session in our database */ |
41 |
do { |
42 |
- ret = DB->store(sessdb, (void *) sess->session_id, |
43 |
- sess->session_id_length, |
44 |
+ ret = DB->store(sessdb, (void *) session_id, session_id_length, |
45 |
(void *) data, len + sizeof(time_t), NULL); |
13 |
} |
46 |
} |
14 |
} |
47 |
while (ret == MYDB_AGAIN); |
15 |
+#endif |
48 |
@@ -255,8 +246,8 @@ static int new_session_cb(SSL * ssl, SSL_SESSION * ses |
|
|
49 |
if (ssl_verbose_logging) { |
50 |
int i; |
51 |
char idstr[SSL_MAX_SSL_SESSION_ID_LENGTH * 2 + 1]; |
52 |
- for (i = 0; i < sess->session_id_length; i++) |
53 |
- sprintf(idstr + i * 2, "%02X", sess->session_id[i]); |
54 |
+ for (i = 0; i < session_id_length; i++) |
55 |
+ sprintf(idstr + i * 2, "%02X", session_id[i]); |
16 |
|
56 |
|
17 |
/* Try the good-old default /dev/urandom, if available */ |
57 |
log_debug("new SSL session: id=%s, expire=%s, status=%s", |
18 |
totbytes += add_rand_file("/dev/urandom"); |
58 |
idstr, ctime(&expire), ret ? "failed" : "ok"); |
19 |
@@ -387,7 +389,7 @@ void ssl_context_init(struct ssl_config |
59 |
@@ -298,7 +289,10 @@ static void remove_session(unsigned char *id, int idle |
|
|
60 |
*/ |
61 |
static void remove_session_cb(SSL_CTX * ctx, SSL_SESSION * sess) |
62 |
{ |
63 |
- remove_session(sess->session_id, sess->session_id_length); |
64 |
+ unsigned int session_id_length; |
65 |
+ unsigned char *session_id = SSL_SESSION_get_id(sess, &session_id_length); |
66 |
+ |
67 |
+ remove_session(session_id, session_id_length); |
68 |
} |
69 |
|
70 |
/* |
71 |
@@ -387,16 +381,17 @@ void ssl_context_init(struct ssl_config *ssl_config) |
20 |
SSL_load_error_strings(); |
72 |
SSL_load_error_strings(); |
21 |
|
73 |
|
22 |
/* Set up client context: only used by accountd */ |
74 |
/* Set up client context: only used by accountd */ |
23 |
- client_ctx = SSL_CTX_new(SSLv3_client_method()); |
75 |
+#if OPENSSL_VERSION_NUMBER < 0x10100000L |
24 |
+ client_ctx = SSL_CTX_new(SSLv23_client_method()); |
76 |
client_ctx = SSL_CTX_new(SSLv3_client_method()); |
|
|
77 |
+#else |
78 |
+ client_ctx = SSL_CTX_new(TLS_client_method()); |
79 |
+#endif |
25 |
SSL_CTX_set_session_cache_mode(client_ctx, SSL_SESS_CACHE_BOTH); |
80 |
SSL_CTX_set_session_cache_mode(client_ctx, SSL_SESS_CACHE_BOTH); |
26 |
SSL_CTX_set_info_callback(client_ctx, info_callback); |
81 |
SSL_CTX_set_info_callback(client_ctx, info_callback); |
27 |
#ifdef SSL_MODE_AUTO_RETRY |
82 |
#ifdef SSL_MODE_AUTO_RETRY |
|
|
83 |
SSL_CTX_set_mode(client_ctx, SSL_MODE_AUTO_RETRY); |
84 |
#endif |
85 |
|
86 |
- if (SSL_CTX_need_tmp_RSA(client_ctx)) |
87 |
- SSL_CTX_set_tmp_rsa_callback(client_ctx, rsa_callback); |
88 |
- |
89 |
/* Don't bother with session cache for client side: not enough |
90 |
* connections to worry about caching */ |
91 |
SSL_CTX_set_session_cache_mode(client_ctx, SSL_SESS_CACHE_OFF); |
92 |
@@ -503,10 +498,6 @@ void ssl_context_init(struct ssl_config *ssl_config) |
93 |
log_fatal("SSL_CTX_set_options(SSL_OP_CIPHER_SERVER_PREFERENCE)" |
94 |
"failed"); |
95 |
|
96 |
- /* Set up RSA temporary key callback routine */ |
97 |
- if (SSL_CTX_need_tmp_RSA(server_ctx)) |
98 |
- SSL_CTX_set_tmp_rsa_callback(server_ctx, rsa_callback); |
99 |
- |
100 |
/* Initialise RSA temporary key (will take a couple of secs to complete) */ |
101 |
ssl_init_rsakey(ssl_config); |
102 |
} |
103 |
@@ -615,7 +606,7 @@ void *ssl_start_server(int fd, unsigned long timeout) |
104 |
else |
105 |
log_debug("SSL: No client certificate"); |
106 |
|
107 |
- switch (ssl->session->ssl_version) { |
108 |
+ switch (SSL_version(ssl)) { |
109 |
case SSL2_VERSION: |
110 |
ver = "SSLv2"; |
111 |
break; |
112 |
@@ -668,7 +659,7 @@ void *ssl_start_client(int fd, unsigned long timeout) |
113 |
|
114 |
/* Verify certificate here? Need local context to play with? */ |
115 |
|
116 |
- switch (((SSL *) ssl)->session->ssl_version) { |
117 |
+ switch (SSL_version(ssl)) { |
118 |
case SSL2_VERSION: |
119 |
ver = "SSLv2"; |
120 |
break; |