Lines 1-6
Link Here
|
1 |
--- third_party/serf/instaweb_ssl_buckets.c.orig 2017-06-08 22:22:39 UTC |
1 |
--- third_party/serf/instaweb_ssl_buckets.c.orig 2017-06-08 22:22:39 UTC |
2 |
+++ third_party/serf/instaweb_ssl_buckets.c |
2 |
+++ third_party/serf/instaweb_ssl_buckets.c |
3 |
@@ -1697,11 +1697,15 @@ int serf_ssl_cert_depth(const serf_ssl_c |
3 |
@@ -253,7 +253,11 @@ apps_ssl_info_callback(const SSL *s, int |
|
|
4 |
/* Returns the amount read. */ |
5 |
static int bio_bucket_read(BIO *bio, char *in, int inlen) |
6 |
{ |
7 |
+#if OPENSSL_VERSION_NUMBER < 0x10100000L |
8 |
serf_ssl_context_t *ctx = bio->ptr; |
9 |
+#else |
10 |
+ serf_ssl_context_t *ctx = BIO_get_data(bio); |
11 |
+#endif |
12 |
const char *data; |
13 |
apr_status_t status; |
14 |
apr_size_t len; |
15 |
@@ -297,7 +301,11 @@ static int bio_bucket_read(BIO *bio, cha |
16 |
/* Returns the amount written. */ |
17 |
static int bio_bucket_write(BIO *bio, const char *in, int inl) |
18 |
{ |
19 |
+#if OPENSSL_VERSION_NUMBER < 0x10100000L |
20 |
serf_ssl_context_t *ctx = bio->ptr; |
21 |
+#else |
22 |
+ serf_ssl_context_t *ctx = BIO_get_data(bio); |
23 |
+#endif |
24 |
serf_bucket_t *tmp; |
25 |
|
26 |
serf__log(SSL_VERBOSE, __FILE__, "bio_bucket_write called for %d bytes\n", |
27 |
@@ -325,7 +333,11 @@ static int bio_bucket_write(BIO *bio, co |
28 |
/* Returns the amount read. */ |
29 |
static int bio_file_read(BIO *bio, char *in, int inlen) |
30 |
{ |
31 |
+#if OPENSSL_VERSION_NUMBER < 0x10100000L |
32 |
apr_file_t *file = bio->ptr; |
33 |
+#else |
34 |
+ apr_file_t *file = BIO_get_data(bio); |
35 |
+#endif |
36 |
apr_status_t status; |
37 |
apr_size_t len; |
38 |
|
39 |
@@ -350,7 +362,11 @@ static int bio_file_read(BIO *bio, char |
40 |
/* Returns the amount written. */ |
41 |
static int bio_file_write(BIO *bio, const char *in, int inl) |
42 |
{ |
43 |
+#if OPENSSL_VERSION_NUMBER < 0x10100000L |
44 |
apr_file_t *file = bio->ptr; |
45 |
+#else |
46 |
+ apr_file_t *file = BIO_get_data(bio); |
47 |
+#endif |
48 |
apr_size_t nbytes; |
49 |
|
50 |
BIO_clear_retry_flags(bio); |
51 |
@@ -368,10 +384,16 @@ static int bio_file_gets(BIO *bio, char |
52 |
|
53 |
static int bio_bucket_create(BIO *bio) |
54 |
{ |
55 |
+#if OPENSSL_VERSION_NUMBER < 0x10100000L |
56 |
bio->shutdown = 1; |
57 |
bio->init = 1; |
58 |
bio->num = -1; |
59 |
bio->ptr = NULL; |
60 |
+#else |
61 |
+ BIO_set_shutdown(bio, 1); |
62 |
+ BIO_set_init(bio, 1); |
63 |
+ BIO_set_data(bio, NULL); |
64 |
+#endif |
65 |
|
66 |
return 1; |
67 |
} |
68 |
@@ -405,6 +427,7 @@ static long bio_bucket_ctrl(BIO *bio, in |
69 |
return ret; |
70 |
} |
71 |
|
72 |
+#if OPENSSL_VERSION_NUMBER < 0x10100000L |
73 |
static BIO_METHOD bio_bucket_method = { |
74 |
BIO_TYPE_MEM, |
75 |
"Serf SSL encryption and decryption buckets", |
76 |
@@ -434,6 +457,11 @@ static BIO_METHOD bio_file_method = { |
77 |
NULL /* sslc does not have the callback_ctrl field */ |
78 |
#endif |
79 |
}; |
80 |
+#else |
81 |
+static BIO_METHOD *bio_bucket_method = NULL; |
82 |
+static BIO_METHOD *bio_file_method = NULL; |
83 |
+#endif |
84 |
+ |
85 |
|
86 |
typedef enum san_copy_t { |
87 |
EscapeNulAndCopy = 0, |
88 |
@@ -1088,7 +1116,9 @@ static void init_ssl_libraries(void) |
89 |
} |
90 |
#endif |
91 |
|
92 |
+#if OPENSSL_VERSION_NUMBER < 0x10100000L |
93 |
CRYPTO_malloc_init(); |
94 |
+#endif |
95 |
ERR_load_crypto_strings(); |
96 |
SSL_load_error_strings(); |
97 |
SSL_library_init(); |
98 |
@@ -1172,8 +1202,22 @@ static int ssl_need_client_cert(SSL *ssl |
99 |
continue; |
100 |
} |
101 |
|
102 |
+#if OPENSSL_VERSION_NUMBER < 0x10100000L |
103 |
bio = BIO_new(&bio_file_method); |
104 |
bio->ptr = cert_file; |
105 |
+#else |
106 |
+ if (bio_file_method == NULL) { |
107 |
+ bio_file_method = BIO_meth_new(BIO_TYPE_FILE, "Wrapper around APR file structures"); |
108 |
+ BIO_meth_set_write(bio_file_method, bio_file_write); |
109 |
+ BIO_meth_set_read(bio_file_method, bio_file_read); |
110 |
+ BIO_meth_set_gets(bio_file_method, bio_file_gets); |
111 |
+ BIO_meth_set_ctrl(bio_file_method, bio_bucket_ctrl); |
112 |
+ BIO_meth_set_create(bio_file_method, bio_bucket_create); |
113 |
+ BIO_meth_set_destroy(bio_file_method, bio_bucket_destroy); |
114 |
+ } |
115 |
+ bio = BIO_new(bio_file_method); |
116 |
+ BIO_set_data(bio, cert_file); |
117 |
+#endif |
118 |
|
119 |
ctx->cert_path = cert_path; |
120 |
p12 = d2i_PKCS12_bio(bio, NULL); |
121 |
@@ -1351,8 +1395,21 @@ static serf_ssl_context_t *ssl_init_cont |
122 |
disable_compression(ssl_ctx); |
123 |
|
124 |
ssl_ctx->ssl = SSL_new(ssl_ctx->ctx); |
125 |
+#if OPENSSL_VERSION_NUMBER < 0x10100000L |
126 |
ssl_ctx->bio = BIO_new(&bio_bucket_method); |
127 |
ssl_ctx->bio->ptr = ssl_ctx; |
128 |
+#else |
129 |
+ if (bio_bucket_method == NULL) { |
130 |
+ bio_bucket_method = BIO_meth_new(BIO_TYPE_MEM, "Serf SSL encryption and decryption buckets"); |
131 |
+ BIO_meth_set_write(bio_bucket_method, bio_bucket_write); |
132 |
+ BIO_meth_set_read(bio_bucket_method, bio_bucket_read); |
133 |
+ BIO_meth_set_ctrl(bio_bucket_method, bio_bucket_ctrl); |
134 |
+ BIO_meth_set_create(bio_bucket_method, bio_bucket_create); |
135 |
+ BIO_meth_set_destroy(bio_bucket_method, bio_bucket_destroy); |
136 |
+ } |
137 |
+ ssl_ctx->bio = BIO_new(bio_bucket_method); |
138 |
+ BIO_set_data(ssl_ctx->bio, ssl_ctx); |
139 |
+#endif |
140 |
|
141 |
SSL_set_bio(ssl_ctx->ssl, ssl_ctx->bio, ssl_ctx->bio); |
142 |
|
143 |
@@ -1697,11 +1754,15 @@ int serf_ssl_cert_depth(const serf_ssl_c |
4 |
int serf_ssl_check_host(const serf_ssl_certificate_t *cert, |
144 |
int serf_ssl_check_host(const serf_ssl_certificate_t *cert, |
5 |
const char* hostname) |
145 |
const char* hostname) |
6 |
{ |
146 |
{ |