]>
Commit | Line | Data |
---|---|---|
846e33c7 RS |
1 | /* |
2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. | |
d02b48c6 | 3 | * |
846e33c7 RS |
4 | * Licensed under the OpenSSL license (the "License"). You may not use |
5 | * this file except in compliance with the License. You can obtain a copy | |
6 | * in the file LICENSE in the source distribution or at | |
7 | * https://www.openssl.org/source/license.html | |
d02b48c6 RE |
8 | */ |
9 | ||
10 | #include <stdio.h> | |
58964a49 | 11 | #include <stdlib.h> |
d02b48c6 RE |
12 | #include <string.h> |
13 | #include <errno.h> | |
ec577822 | 14 | #include <openssl/crypto.h> |
a146ae55 | 15 | #include "internal/bio.h" |
ec577822 | 16 | #include <openssl/err.h> |
b6ba4014 | 17 | #include "ssl_locl.h" |
d02b48c6 | 18 | |
f42fd819 MC |
19 | static int ssl_write(BIO *h, const char *buf, size_t size, size_t *written); |
20 | static int ssl_read(BIO *b, char *buf, size_t size, size_t *readbytes); | |
0e1c0612 UM |
21 | static int ssl_puts(BIO *h, const char *str); |
22 | static long ssl_ctrl(BIO *h, int cmd, long arg1, void *arg2); | |
d02b48c6 RE |
23 | static int ssl_new(BIO *h); |
24 | static int ssl_free(BIO *data); | |
13083215 | 25 | static long ssl_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); |
0f113f3e MC |
26 | typedef struct bio_ssl_st { |
27 | SSL *ssl; /* The ssl handle :-) */ | |
28 | /* re-negotiate every time the total number of bytes is this size */ | |
29 | int num_renegotiates; | |
30 | unsigned long renegotiate_count; | |
8051ab2b | 31 | size_t byte_count; |
0f113f3e MC |
32 | unsigned long renegotiate_timeout; |
33 | unsigned long last_time; | |
34 | } BIO_SSL; | |
35 | ||
04f6b0fd | 36 | static const BIO_METHOD methods_sslp = { |
0f113f3e MC |
37 | BIO_TYPE_SSL, "ssl", |
38 | ssl_write, | |
3befffa3 | 39 | NULL, |
0f113f3e | 40 | ssl_read, |
d07aee2c | 41 | NULL, |
0f113f3e MC |
42 | ssl_puts, |
43 | NULL, /* ssl_gets, */ | |
44 | ssl_ctrl, | |
45 | ssl_new, | |
46 | ssl_free, | |
47 | ssl_callback_ctrl, | |
48 | }; | |
a9188d4e | 49 | |
04f6b0fd | 50 | const BIO_METHOD *BIO_f_ssl(void) |
0f113f3e MC |
51 | { |
52 | return (&methods_sslp); | |
53 | } | |
d02b48c6 | 54 | |
6b691a5c | 55 | static int ssl_new(BIO *bi) |
0f113f3e | 56 | { |
b51bce94 | 57 | BIO_SSL *bs = OPENSSL_zalloc(sizeof(*bs)); |
0f113f3e | 58 | |
0f113f3e MC |
59 | if (bs == NULL) { |
60 | BIOerr(BIO_F_SSL_NEW, ERR_R_MALLOC_FAILURE); | |
61 | return (0); | |
62 | } | |
a146ae55 MC |
63 | BIO_set_init(bi, 0); |
64 | BIO_set_data(bi, bs); | |
65 | /* Clear all flags */ | |
66 | BIO_clear_flags(bi, ~0); | |
67 | ||
68 | return 1; | |
0f113f3e | 69 | } |
d02b48c6 | 70 | |
6b691a5c | 71 | static int ssl_free(BIO *a) |
0f113f3e MC |
72 | { |
73 | BIO_SSL *bs; | |
74 | ||
75 | if (a == NULL) | |
76 | return (0); | |
a146ae55 | 77 | bs = BIO_get_data(a); |
0f113f3e MC |
78 | if (bs->ssl != NULL) |
79 | SSL_shutdown(bs->ssl); | |
a146ae55 MC |
80 | if (BIO_get_shutdown(a)) { |
81 | if (BIO_get_init(a)) | |
0f113f3e | 82 | SSL_free(bs->ssl); |
a146ae55 MC |
83 | /* Clear all flags */ |
84 | BIO_clear_flags(a, ~0); | |
85 | BIO_set_init(a, 0); | |
0f113f3e | 86 | } |
a146ae55 MC |
87 | OPENSSL_free(bs); |
88 | return 1; | |
0f113f3e MC |
89 | } |
90 | ||
f42fd819 | 91 | static int ssl_read(BIO *b, char *buf, size_t size, size_t *readbytes) |
0f113f3e MC |
92 | { |
93 | int ret = 1; | |
94 | BIO_SSL *sb; | |
95 | SSL *ssl; | |
96 | int retry_reason = 0; | |
97 | int r = 0; | |
d02b48c6 | 98 | |
f42fd819 MC |
99 | if (buf == NULL) |
100 | return 0; | |
a146ae55 | 101 | sb = BIO_get_data(b); |
0f113f3e | 102 | ssl = sb->ssl; |
d02b48c6 | 103 | |
0f113f3e | 104 | BIO_clear_retry_flags(b); |
d02b48c6 | 105 | |
699ae859 | 106 | ret = SSL_read_ex(ssl, buf, size, readbytes); |
0f113f3e MC |
107 | |
108 | switch (SSL_get_error(ssl, ret)) { | |
109 | case SSL_ERROR_NONE: | |
0f113f3e | 110 | if (sb->renegotiate_count > 0) { |
ac0edec1 | 111 | sb->byte_count += *readbytes; |
0f113f3e MC |
112 | if (sb->byte_count > sb->renegotiate_count) { |
113 | sb->byte_count = 0; | |
114 | sb->num_renegotiates++; | |
115 | SSL_renegotiate(ssl); | |
116 | r = 1; | |
117 | } | |
118 | } | |
119 | if ((sb->renegotiate_timeout > 0) && (!r)) { | |
120 | unsigned long tm; | |
121 | ||
122 | tm = (unsigned long)time(NULL); | |
123 | if (tm > sb->last_time + sb->renegotiate_timeout) { | |
124 | sb->last_time = tm; | |
125 | sb->num_renegotiates++; | |
126 | SSL_renegotiate(ssl); | |
127 | } | |
128 | } | |
129 | ||
130 | break; | |
131 | case SSL_ERROR_WANT_READ: | |
132 | BIO_set_retry_read(b); | |
133 | break; | |
134 | case SSL_ERROR_WANT_WRITE: | |
135 | BIO_set_retry_write(b); | |
136 | break; | |
137 | case SSL_ERROR_WANT_X509_LOOKUP: | |
138 | BIO_set_retry_special(b); | |
139 | retry_reason = BIO_RR_SSL_X509_LOOKUP; | |
140 | break; | |
141 | case SSL_ERROR_WANT_ACCEPT: | |
142 | BIO_set_retry_special(b); | |
143 | retry_reason = BIO_RR_ACCEPT; | |
144 | break; | |
145 | case SSL_ERROR_WANT_CONNECT: | |
146 | BIO_set_retry_special(b); | |
147 | retry_reason = BIO_RR_CONNECT; | |
148 | break; | |
149 | case SSL_ERROR_SYSCALL: | |
150 | case SSL_ERROR_SSL: | |
151 | case SSL_ERROR_ZERO_RETURN: | |
152 | default: | |
153 | break; | |
154 | } | |
155 | ||
a146ae55 | 156 | BIO_set_retry_reason(b, retry_reason); |
d07aee2c | 157 | |
3befffa3 | 158 | return ret; |
0f113f3e | 159 | } |
d02b48c6 | 160 | |
f42fd819 | 161 | static int ssl_write(BIO *b, const char *buf, size_t size, size_t *written) |
0f113f3e MC |
162 | { |
163 | int ret, r = 0; | |
164 | int retry_reason = 0; | |
165 | SSL *ssl; | |
166 | BIO_SSL *bs; | |
167 | ||
f42fd819 MC |
168 | if (buf == NULL) |
169 | return 0; | |
a146ae55 | 170 | bs = BIO_get_data(b); |
0f113f3e MC |
171 | ssl = bs->ssl; |
172 | ||
173 | BIO_clear_retry_flags(b); | |
174 | ||
8051ab2b | 175 | ret = SSL_write_ex(ssl, buf, size, written); |
0f113f3e MC |
176 | |
177 | switch (SSL_get_error(ssl, ret)) { | |
178 | case SSL_ERROR_NONE: | |
0f113f3e | 179 | if (bs->renegotiate_count > 0) { |
8051ab2b | 180 | bs->byte_count += *written; |
0f113f3e MC |
181 | if (bs->byte_count > bs->renegotiate_count) { |
182 | bs->byte_count = 0; | |
183 | bs->num_renegotiates++; | |
184 | SSL_renegotiate(ssl); | |
185 | r = 1; | |
186 | } | |
187 | } | |
188 | if ((bs->renegotiate_timeout > 0) && (!r)) { | |
189 | unsigned long tm; | |
190 | ||
191 | tm = (unsigned long)time(NULL); | |
192 | if (tm > bs->last_time + bs->renegotiate_timeout) { | |
193 | bs->last_time = tm; | |
194 | bs->num_renegotiates++; | |
195 | SSL_renegotiate(ssl); | |
196 | } | |
197 | } | |
198 | break; | |
199 | case SSL_ERROR_WANT_WRITE: | |
200 | BIO_set_retry_write(b); | |
201 | break; | |
202 | case SSL_ERROR_WANT_READ: | |
203 | BIO_set_retry_read(b); | |
204 | break; | |
205 | case SSL_ERROR_WANT_X509_LOOKUP: | |
206 | BIO_set_retry_special(b); | |
207 | retry_reason = BIO_RR_SSL_X509_LOOKUP; | |
208 | break; | |
209 | case SSL_ERROR_WANT_CONNECT: | |
210 | BIO_set_retry_special(b); | |
211 | retry_reason = BIO_RR_CONNECT; | |
212 | case SSL_ERROR_SYSCALL: | |
213 | case SSL_ERROR_SSL: | |
214 | default: | |
215 | break; | |
216 | } | |
217 | ||
a146ae55 | 218 | BIO_set_retry_reason(b, retry_reason); |
3befffa3 | 219 | |
a146ae55 | 220 | return ret; |
0f113f3e | 221 | } |
d02b48c6 | 222 | |
0e1c0612 | 223 | static long ssl_ctrl(BIO *b, int cmd, long num, void *ptr) |
0f113f3e MC |
224 | { |
225 | SSL **sslp, *ssl; | |
a146ae55 | 226 | BIO_SSL *bs, *dbs; |
0f113f3e MC |
227 | BIO *dbio, *bio; |
228 | long ret = 1; | |
a146ae55 | 229 | BIO *next; |
0f113f3e | 230 | |
a146ae55 MC |
231 | bs = BIO_get_data(b); |
232 | next = BIO_next(b); | |
0f113f3e MC |
233 | ssl = bs->ssl; |
234 | if ((ssl == NULL) && (cmd != BIO_C_SET_SSL)) | |
235 | return (0); | |
236 | switch (cmd) { | |
237 | case BIO_CTRL_RESET: | |
238 | SSL_shutdown(ssl); | |
239 | ||
240 | if (ssl->handshake_func == ssl->method->ssl_connect) | |
241 | SSL_set_connect_state(ssl); | |
242 | else if (ssl->handshake_func == ssl->method->ssl_accept) | |
243 | SSL_set_accept_state(ssl); | |
244 | ||
61986d32 | 245 | if (!SSL_clear(ssl)) { |
69f68237 MC |
246 | ret = 0; |
247 | break; | |
248 | } | |
0f113f3e | 249 | |
a146ae55 MC |
250 | if (next != NULL) |
251 | ret = BIO_ctrl(next, cmd, num, ptr); | |
0f113f3e MC |
252 | else if (ssl->rbio != NULL) |
253 | ret = BIO_ctrl(ssl->rbio, cmd, num, ptr); | |
254 | else | |
255 | ret = 1; | |
256 | break; | |
257 | case BIO_CTRL_INFO: | |
258 | ret = 0; | |
259 | break; | |
260 | case BIO_C_SSL_MODE: | |
261 | if (num) /* client mode */ | |
262 | SSL_set_connect_state(ssl); | |
263 | else | |
264 | SSL_set_accept_state(ssl); | |
265 | break; | |
266 | case BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT: | |
267 | ret = bs->renegotiate_timeout; | |
268 | if (num < 60) | |
269 | num = 5; | |
270 | bs->renegotiate_timeout = (unsigned long)num; | |
271 | bs->last_time = (unsigned long)time(NULL); | |
272 | break; | |
273 | case BIO_C_SET_SSL_RENEGOTIATE_BYTES: | |
274 | ret = bs->renegotiate_count; | |
275 | if ((long)num >= 512) | |
276 | bs->renegotiate_count = (unsigned long)num; | |
277 | break; | |
278 | case BIO_C_GET_SSL_NUM_RENEGOTIATES: | |
279 | ret = bs->num_renegotiates; | |
280 | break; | |
281 | case BIO_C_SET_SSL: | |
282 | if (ssl != NULL) { | |
283 | ssl_free(b); | |
284 | if (!ssl_new(b)) | |
285 | return 0; | |
286 | } | |
a146ae55 | 287 | BIO_set_shutdown(b, num); |
0f113f3e | 288 | ssl = (SSL *)ptr; |
a146ae55 | 289 | bs->ssl = ssl; |
0f113f3e MC |
290 | bio = SSL_get_rbio(ssl); |
291 | if (bio != NULL) { | |
a146ae55 MC |
292 | if (next != NULL) |
293 | BIO_push(bio, next); | |
294 | BIO_set_next(b, bio); | |
fb46be03 | 295 | BIO_up_ref(bio); |
0f113f3e | 296 | } |
a146ae55 | 297 | BIO_set_init(b, 1); |
0f113f3e MC |
298 | break; |
299 | case BIO_C_GET_SSL: | |
300 | if (ptr != NULL) { | |
301 | sslp = (SSL **)ptr; | |
302 | *sslp = ssl; | |
303 | } else | |
304 | ret = 0; | |
305 | break; | |
306 | case BIO_CTRL_GET_CLOSE: | |
a146ae55 | 307 | ret = BIO_get_shutdown(b); |
0f113f3e MC |
308 | break; |
309 | case BIO_CTRL_SET_CLOSE: | |
a146ae55 | 310 | BIO_set_shutdown(b, (int)num); |
0f113f3e MC |
311 | break; |
312 | case BIO_CTRL_WPENDING: | |
313 | ret = BIO_ctrl(ssl->wbio, cmd, num, ptr); | |
314 | break; | |
315 | case BIO_CTRL_PENDING: | |
316 | ret = SSL_pending(ssl); | |
317 | if (ret == 0) | |
318 | ret = BIO_pending(ssl->rbio); | |
319 | break; | |
320 | case BIO_CTRL_FLUSH: | |
321 | BIO_clear_retry_flags(b); | |
322 | ret = BIO_ctrl(ssl->wbio, cmd, num, ptr); | |
323 | BIO_copy_next_retry(b); | |
324 | break; | |
325 | case BIO_CTRL_PUSH: | |
a146ae55 | 326 | if ((next != NULL) && (next != ssl->rbio)) { |
eddef305 MC |
327 | /* |
328 | * We are going to pass ownership of next to the SSL object...but | |
329 | * we don't own a reference to pass yet - so up ref | |
330 | */ | |
331 | BIO_up_ref(next); | |
a146ae55 | 332 | SSL_set_bio(ssl, next, next); |
0f113f3e MC |
333 | } |
334 | break; | |
335 | case BIO_CTRL_POP: | |
336 | /* Only detach if we are the BIO explicitly being popped */ | |
337 | if (b == ptr) { | |
b46fe860 MC |
338 | /* This will clear the reference we obtained during push */ |
339 | SSL_set_bio(ssl, NULL, NULL); | |
0f113f3e MC |
340 | } |
341 | break; | |
342 | case BIO_C_DO_STATE_MACHINE: | |
343 | BIO_clear_retry_flags(b); | |
344 | ||
a146ae55 | 345 | BIO_set_retry_reason(b, 0); |
0f113f3e MC |
346 | ret = (int)SSL_do_handshake(ssl); |
347 | ||
348 | switch (SSL_get_error(ssl, (int)ret)) { | |
349 | case SSL_ERROR_WANT_READ: | |
350 | BIO_set_flags(b, BIO_FLAGS_READ | BIO_FLAGS_SHOULD_RETRY); | |
351 | break; | |
352 | case SSL_ERROR_WANT_WRITE: | |
353 | BIO_set_flags(b, BIO_FLAGS_WRITE | BIO_FLAGS_SHOULD_RETRY); | |
354 | break; | |
355 | case SSL_ERROR_WANT_CONNECT: | |
356 | BIO_set_flags(b, BIO_FLAGS_IO_SPECIAL | BIO_FLAGS_SHOULD_RETRY); | |
a146ae55 | 357 | BIO_set_retry_reason(b, BIO_get_retry_reason(next)); |
0f113f3e | 358 | break; |
f1c412c9 DSH |
359 | case SSL_ERROR_WANT_X509_LOOKUP: |
360 | BIO_set_retry_special(b); | |
a146ae55 | 361 | BIO_set_retry_reason(b, BIO_RR_SSL_X509_LOOKUP); |
f1c412c9 | 362 | break; |
0f113f3e MC |
363 | default: |
364 | break; | |
365 | } | |
366 | break; | |
367 | case BIO_CTRL_DUP: | |
368 | dbio = (BIO *)ptr; | |
a146ae55 MC |
369 | dbs = BIO_get_data(dbio); |
370 | SSL_free(dbs->ssl); | |
371 | dbs->ssl = SSL_dup(ssl); | |
dbd5c34f MC |
372 | dbs->num_renegotiates = bs->num_renegotiates; |
373 | dbs->renegotiate_count = bs->renegotiate_count; | |
374 | dbs->byte_count = bs->byte_count; | |
375 | dbs->renegotiate_timeout = bs->renegotiate_timeout; | |
376 | dbs->last_time = bs->last_time; | |
a146ae55 | 377 | ret = (dbs->ssl != NULL); |
0f113f3e MC |
378 | break; |
379 | case BIO_C_GET_FD: | |
380 | ret = BIO_ctrl(ssl->rbio, cmd, num, ptr); | |
381 | break; | |
382 | case BIO_CTRL_SET_CALLBACK: | |
383 | { | |
384 | #if 0 /* FIXME: Should this be used? -- Richard | |
385 | * Levitte */ | |
386 | SSLerr(SSL_F_SSL_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | |
387 | ret = -1; | |
d3442bc7 | 388 | #else |
0f113f3e | 389 | ret = 0; |
d3442bc7 | 390 | #endif |
0f113f3e MC |
391 | } |
392 | break; | |
393 | case BIO_CTRL_GET_CALLBACK: | |
394 | { | |
395 | void (**fptr) (const SSL *xssl, int type, int val); | |
396 | ||
397 | fptr = (void (**)(const SSL *xssl, int type, int val))ptr; | |
398 | *fptr = SSL_get_info_callback(ssl); | |
399 | } | |
400 | break; | |
401 | default: | |
402 | ret = BIO_ctrl(ssl->rbio, cmd, num, ptr); | |
403 | break; | |
404 | } | |
405 | return (ret); | |
406 | } | |
d02b48c6 | 407 | |
13083215 | 408 | static long ssl_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) |
0f113f3e MC |
409 | { |
410 | SSL *ssl; | |
411 | BIO_SSL *bs; | |
412 | long ret = 1; | |
413 | ||
a146ae55 | 414 | bs = BIO_get_data(b); |
0f113f3e MC |
415 | ssl = bs->ssl; |
416 | switch (cmd) { | |
417 | case BIO_CTRL_SET_CALLBACK: | |
418 | { | |
419 | /* | |
420 | * FIXME: setting this via a completely different prototype seems | |
421 | * like a crap idea | |
422 | */ | |
423 | SSL_set_info_callback(ssl, (void (*)(const SSL *, int, int))fp); | |
424 | } | |
425 | break; | |
426 | default: | |
427 | ret = BIO_callback_ctrl(ssl->rbio, cmd, fp); | |
428 | break; | |
429 | } | |
430 | return (ret); | |
431 | } | |
d3442bc7 | 432 | |
0e1c0612 | 433 | static int ssl_puts(BIO *bp, const char *str) |
0f113f3e MC |
434 | { |
435 | int n, ret; | |
d02b48c6 | 436 | |
0f113f3e MC |
437 | n = strlen(str); |
438 | ret = BIO_write(bp, str, n); | |
439 | return (ret); | |
440 | } | |
d02b48c6 | 441 | |
6b691a5c | 442 | BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx) |
0f113f3e | 443 | { |
85d686e7 | 444 | #ifndef OPENSSL_NO_SOCK |
0f113f3e MC |
445 | BIO *ret = NULL, *buf = NULL, *ssl = NULL; |
446 | ||
447 | if ((buf = BIO_new(BIO_f_buffer())) == NULL) | |
448 | return (NULL); | |
449 | if ((ssl = BIO_new_ssl_connect(ctx)) == NULL) | |
450 | goto err; | |
451 | if ((ret = BIO_push(buf, ssl)) == NULL) | |
452 | goto err; | |
453 | return (ret); | |
454 | err: | |
ca3a82c3 RS |
455 | BIO_free(buf); |
456 | BIO_free(ssl); | |
85d686e7 | 457 | #endif |
0f113f3e MC |
458 | return (NULL); |
459 | } | |
58964a49 | 460 | |
6b691a5c | 461 | BIO *BIO_new_ssl_connect(SSL_CTX *ctx) |
0f113f3e | 462 | { |
4a1fbd13 | 463 | #ifndef OPENSSL_NO_SOCK |
0f113f3e MC |
464 | BIO *ret = NULL, *con = NULL, *ssl = NULL; |
465 | ||
466 | if ((con = BIO_new(BIO_s_connect())) == NULL) | |
467 | return (NULL); | |
468 | if ((ssl = BIO_new_ssl(ctx, 1)) == NULL) | |
469 | goto err; | |
470 | if ((ret = BIO_push(ssl, con)) == NULL) | |
471 | goto err; | |
472 | return (ret); | |
473 | err: | |
ca3a82c3 | 474 | BIO_free(con); |
4a1fbd13 | 475 | #endif |
0f113f3e MC |
476 | return (NULL); |
477 | } | |
58964a49 | 478 | |
6b691a5c | 479 | BIO *BIO_new_ssl(SSL_CTX *ctx, int client) |
0f113f3e MC |
480 | { |
481 | BIO *ret; | |
482 | SSL *ssl; | |
483 | ||
484 | if ((ret = BIO_new(BIO_f_ssl())) == NULL) | |
485 | return (NULL); | |
486 | if ((ssl = SSL_new(ctx)) == NULL) { | |
487 | BIO_free(ret); | |
488 | return (NULL); | |
489 | } | |
490 | if (client) | |
491 | SSL_set_connect_state(ssl); | |
492 | else | |
493 | SSL_set_accept_state(ssl); | |
494 | ||
495 | BIO_set_ssl(ret, ssl, BIO_CLOSE); | |
496 | return (ret); | |
497 | } | |
d02b48c6 | 498 | |
6b691a5c | 499 | int BIO_ssl_copy_session_id(BIO *t, BIO *f) |
0f113f3e | 500 | { |
a146ae55 | 501 | BIO_SSL *tdata, *fdata; |
0f113f3e MC |
502 | t = BIO_find_type(t, BIO_TYPE_SSL); |
503 | f = BIO_find_type(f, BIO_TYPE_SSL); | |
504 | if ((t == NULL) || (f == NULL)) | |
a146ae55 MC |
505 | return 0; |
506 | tdata = BIO_get_data(t); | |
507 | fdata = BIO_get_data(f); | |
508 | if ((tdata->ssl == NULL) || (fdata->ssl == NULL)) | |
0f113f3e | 509 | return (0); |
a146ae55 | 510 | if (!SSL_copy_session_id(tdata->ssl, (fdata->ssl))) |
17dd65e6 | 511 | return 0; |
0f113f3e MC |
512 | return (1); |
513 | } | |
d02b48c6 | 514 | |
6b691a5c | 515 | void BIO_ssl_shutdown(BIO *b) |
0f113f3e MC |
516 | { |
517 | SSL *s; | |
518 | ||
a146ae55 MC |
519 | b = BIO_find_type(b, BIO_TYPE_SSL); |
520 | if (b == NULL) | |
521 | return; | |
522 | ||
523 | s = BIO_get_data(b); | |
524 | SSL_shutdown(s); | |
0f113f3e | 525 | } |