Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

ssl_file.c 16 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  2. * All rights reserved.
  3. *
  4. * This package is an SSL implementation written
  5. * by Eric Young (eay@cryptsoft.com).
  6. * The implementation was written so as to conform with Netscapes SSL.
  7. *
  8. * This library is free for commercial and non-commercial use as long as
  9. * the following conditions are aheared to. The following conditions
  10. * apply to all code found in this distribution, be it the RC4, RSA,
  11. * lhash, DES, etc., code; not just the SSL code. The SSL documentation
  12. * included with this distribution is covered by the same copyright terms
  13. * except that the holder is Tim Hudson (tjh@cryptsoft.com).
  14. *
  15. * Copyright remains Eric Young's, and as such any Copyright notices in
  16. * the code are not to be removed.
  17. * If this package is used in a product, Eric Young should be given attribution
  18. * as the author of the parts of the library used.
  19. * This can be in the form of a textual message at program startup or
  20. * in documentation (online or textual) provided with the package.
  21. *
  22. * Redistribution and use in source and binary forms, with or without
  23. * modification, are permitted provided that the following conditions
  24. * are met:
  25. * 1. Redistributions of source code must retain the copyright
  26. * notice, this list of conditions and the following disclaimer.
  27. * 2. Redistributions in binary form must reproduce the above copyright
  28. * notice, this list of conditions and the following disclaimer in the
  29. * documentation and/or other materials provided with the distribution.
  30. * 3. All advertising materials mentioning features or use of this software
  31. * must display the following acknowledgement:
  32. * "This product includes cryptographic software written by
  33. * Eric Young (eay@cryptsoft.com)"
  34. * The word 'cryptographic' can be left out if the rouines from the library
  35. * being used are not cryptographic related :-).
  36. * 4. If you include any Windows specific code (or a derivative thereof) from
  37. * the apps directory (application code) you must include an acknowledgement:
  38. * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
  39. *
  40. * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  41. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  42. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  43. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  44. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  45. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  46. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  47. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  48. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  49. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  50. * SUCH DAMAGE.
  51. *
  52. * The licence and distribution terms for any publically available version or
  53. * derivative of this code cannot be changed. i.e. this code cannot simply be
  54. * copied and put under another distribution licence
  55. * [including the GNU Public Licence.]
  56. */
  57. /* ====================================================================
  58. * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved.
  59. *
  60. * Redistribution and use in source and binary forms, with or without
  61. * modification, are permitted provided that the following conditions
  62. * are met:
  63. *
  64. * 1. Redistributions of source code must retain the above copyright
  65. * notice, this list of conditions and the following disclaimer.
  66. *
  67. * 2. Redistributions in binary form must reproduce the above copyright
  68. * notice, this list of conditions and the following disclaimer in
  69. * the documentation and/or other materials provided with the
  70. * distribution.
  71. *
  72. * 3. All advertising materials mentioning features or use of this
  73. * software must display the following acknowledgment:
  74. * "This product includes software developed by the OpenSSL Project
  75. * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
  76. *
  77. * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
  78. * endorse or promote products derived from this software without
  79. * prior written permission. For written permission, please contact
  80. * openssl-core@openssl.org.
  81. *
  82. * 5. Products derived from this software may not be called "OpenSSL"
  83. * nor may "OpenSSL" appear in their names without prior written
  84. * permission of the OpenSSL Project.
  85. *
  86. * 6. Redistributions of any form whatsoever must retain the following
  87. * acknowledgment:
  88. * "This product includes software developed by the OpenSSL Project
  89. * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
  90. *
  91. * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
  92. * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  93. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  94. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
  95. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  96. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  97. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  98. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  99. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  100. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  101. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  102. * OF THE POSSIBILITY OF SUCH DAMAGE.
  103. * ====================================================================
  104. *
  105. * This product includes cryptographic software written by Eric Young
  106. * (eay@cryptsoft.com). This product includes software written by Tim
  107. * Hudson (tjh@cryptsoft.com).
  108. *
  109. */
  110. #include <openssl/ssl.h>
  111. #include <errno.h>
  112. #include <string.h>
  113. #include <openssl/asn1.h>
  114. #include <openssl/bio.h>
  115. #include <openssl/err.h>
  116. #include <openssl/mem.h>
  117. #include <openssl/pem.h>
  118. #include <openssl/stack.h>
  119. #include <openssl/x509.h>
  120. #include "internal.h"
  121. static int xname_cmp(const X509_NAME **a, const X509_NAME **b) {
  122. return X509_NAME_cmp(*a, *b);
  123. }
  124. /* TODO(davidben): Is there any reason this doesn't call
  125. * |SSL_add_file_cert_subjects_to_stack|? */
  126. STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file) {
  127. BIO *in;
  128. X509 *x = NULL;
  129. X509_NAME *xn = NULL;
  130. STACK_OF(X509_NAME) *ret = NULL, *sk;
  131. sk = sk_X509_NAME_new(xname_cmp);
  132. in = BIO_new(BIO_s_file());
  133. if (sk == NULL || in == NULL) {
  134. OPENSSL_PUT_ERROR(SSL, ERR_R_MALLOC_FAILURE);
  135. goto err;
  136. }
  137. if (!BIO_read_filename(in, file)) {
  138. goto err;
  139. }
  140. for (;;) {
  141. if (PEM_read_bio_X509(in, &x, NULL, NULL) == NULL) {
  142. break;
  143. }
  144. if (ret == NULL) {
  145. ret = sk_X509_NAME_new_null();
  146. if (ret == NULL) {
  147. OPENSSL_PUT_ERROR(SSL, ERR_R_MALLOC_FAILURE);
  148. goto err;
  149. }
  150. }
  151. xn = X509_get_subject_name(x);
  152. if (xn == NULL) {
  153. goto err;
  154. }
  155. /* check for duplicates */
  156. xn = X509_NAME_dup(xn);
  157. if (xn == NULL) {
  158. goto err;
  159. }
  160. if (sk_X509_NAME_find(sk, NULL, xn)) {
  161. X509_NAME_free(xn);
  162. } else {
  163. sk_X509_NAME_push(sk, xn);
  164. sk_X509_NAME_push(ret, xn);
  165. }
  166. }
  167. if (0) {
  168. err:
  169. sk_X509_NAME_pop_free(ret, X509_NAME_free);
  170. ret = NULL;
  171. }
  172. sk_X509_NAME_free(sk);
  173. BIO_free(in);
  174. X509_free(x);
  175. if (ret != NULL) {
  176. ERR_clear_error();
  177. }
  178. return ret;
  179. }
  180. int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
  181. const char *file) {
  182. BIO *in;
  183. X509 *x = NULL;
  184. X509_NAME *xn = NULL;
  185. int ret = 1;
  186. int (*oldcmp)(const X509_NAME **a, const X509_NAME **b);
  187. oldcmp = sk_X509_NAME_set_cmp_func(stack, xname_cmp);
  188. in = BIO_new(BIO_s_file());
  189. if (in == NULL) {
  190. OPENSSL_PUT_ERROR(SSL, ERR_R_MALLOC_FAILURE);
  191. goto err;
  192. }
  193. if (!BIO_read_filename(in, file)) {
  194. goto err;
  195. }
  196. for (;;) {
  197. if (PEM_read_bio_X509(in, &x, NULL, NULL) == NULL) {
  198. break;
  199. }
  200. xn = X509_get_subject_name(x);
  201. if (xn == NULL) {
  202. goto err;
  203. }
  204. xn = X509_NAME_dup(xn);
  205. if (xn == NULL) {
  206. goto err;
  207. }
  208. if (sk_X509_NAME_find(stack, NULL, xn)) {
  209. X509_NAME_free(xn);
  210. } else {
  211. sk_X509_NAME_push(stack, xn);
  212. }
  213. }
  214. ERR_clear_error();
  215. if (0) {
  216. err:
  217. ret = 0;
  218. }
  219. BIO_free(in);
  220. X509_free(x);
  221. (void) sk_X509_NAME_set_cmp_func(stack, oldcmp);
  222. return ret;
  223. }
  224. int SSL_use_certificate_file(SSL *ssl, const char *file, int type) {
  225. int reason_code;
  226. BIO *in;
  227. int ret = 0;
  228. X509 *x = NULL;
  229. in = BIO_new(BIO_s_file());
  230. if (in == NULL) {
  231. OPENSSL_PUT_ERROR(SSL, ERR_R_BUF_LIB);
  232. goto end;
  233. }
  234. if (BIO_read_filename(in, file) <= 0) {
  235. OPENSSL_PUT_ERROR(SSL, ERR_R_SYS_LIB);
  236. goto end;
  237. }
  238. if (type == SSL_FILETYPE_ASN1) {
  239. reason_code = ERR_R_ASN1_LIB;
  240. x = d2i_X509_bio(in, NULL);
  241. } else if (type == SSL_FILETYPE_PEM) {
  242. reason_code = ERR_R_PEM_LIB;
  243. x = PEM_read_bio_X509(in, NULL, ssl->ctx->default_passwd_callback,
  244. ssl->ctx->default_passwd_callback_userdata);
  245. } else {
  246. OPENSSL_PUT_ERROR(SSL, SSL_R_BAD_SSL_FILETYPE);
  247. goto end;
  248. }
  249. if (x == NULL) {
  250. OPENSSL_PUT_ERROR(SSL, reason_code);
  251. goto end;
  252. }
  253. ret = SSL_use_certificate(ssl, x);
  254. end:
  255. X509_free(x);
  256. BIO_free(in);
  257. return ret;
  258. }
  259. int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type) {
  260. int reason_code, ret = 0;
  261. BIO *in;
  262. RSA *rsa = NULL;
  263. in = BIO_new(BIO_s_file());
  264. if (in == NULL) {
  265. OPENSSL_PUT_ERROR(SSL, ERR_R_BUF_LIB);
  266. goto end;
  267. }
  268. if (BIO_read_filename(in, file) <= 0) {
  269. OPENSSL_PUT_ERROR(SSL, ERR_R_SYS_LIB);
  270. goto end;
  271. }
  272. if (type == SSL_FILETYPE_ASN1) {
  273. reason_code = ERR_R_ASN1_LIB;
  274. rsa = d2i_RSAPrivateKey_bio(in, NULL);
  275. } else if (type == SSL_FILETYPE_PEM) {
  276. reason_code = ERR_R_PEM_LIB;
  277. rsa =
  278. PEM_read_bio_RSAPrivateKey(in, NULL, ssl->ctx->default_passwd_callback,
  279. ssl->ctx->default_passwd_callback_userdata);
  280. } else {
  281. OPENSSL_PUT_ERROR(SSL, SSL_R_BAD_SSL_FILETYPE);
  282. goto end;
  283. }
  284. if (rsa == NULL) {
  285. OPENSSL_PUT_ERROR(SSL, reason_code);
  286. goto end;
  287. }
  288. ret = SSL_use_RSAPrivateKey(ssl, rsa);
  289. RSA_free(rsa);
  290. end:
  291. BIO_free(in);
  292. return ret;
  293. }
  294. int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type) {
  295. int reason_code, ret = 0;
  296. BIO *in;
  297. EVP_PKEY *pkey = NULL;
  298. in = BIO_new(BIO_s_file());
  299. if (in == NULL) {
  300. OPENSSL_PUT_ERROR(SSL, ERR_R_BUF_LIB);
  301. goto end;
  302. }
  303. if (BIO_read_filename(in, file) <= 0) {
  304. OPENSSL_PUT_ERROR(SSL, ERR_R_SYS_LIB);
  305. goto end;
  306. }
  307. if (type == SSL_FILETYPE_PEM) {
  308. reason_code = ERR_R_PEM_LIB;
  309. pkey = PEM_read_bio_PrivateKey(in, NULL, ssl->ctx->default_passwd_callback,
  310. ssl->ctx->default_passwd_callback_userdata);
  311. } else if (type == SSL_FILETYPE_ASN1) {
  312. reason_code = ERR_R_ASN1_LIB;
  313. pkey = d2i_PrivateKey_bio(in, NULL);
  314. } else {
  315. OPENSSL_PUT_ERROR(SSL, SSL_R_BAD_SSL_FILETYPE);
  316. goto end;
  317. }
  318. if (pkey == NULL) {
  319. OPENSSL_PUT_ERROR(SSL, reason_code);
  320. goto end;
  321. }
  322. ret = SSL_use_PrivateKey(ssl, pkey);
  323. EVP_PKEY_free(pkey);
  324. end:
  325. BIO_free(in);
  326. return ret;
  327. }
  328. int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type) {
  329. int reason_code;
  330. BIO *in;
  331. int ret = 0;
  332. X509 *x = NULL;
  333. in = BIO_new(BIO_s_file());
  334. if (in == NULL) {
  335. OPENSSL_PUT_ERROR(SSL, ERR_R_BUF_LIB);
  336. goto end;
  337. }
  338. if (BIO_read_filename(in, file) <= 0) {
  339. OPENSSL_PUT_ERROR(SSL, ERR_R_SYS_LIB);
  340. goto end;
  341. }
  342. if (type == SSL_FILETYPE_ASN1) {
  343. reason_code = ERR_R_ASN1_LIB;
  344. x = d2i_X509_bio(in, NULL);
  345. } else if (type == SSL_FILETYPE_PEM) {
  346. reason_code = ERR_R_PEM_LIB;
  347. x = PEM_read_bio_X509(in, NULL, ctx->default_passwd_callback,
  348. ctx->default_passwd_callback_userdata);
  349. } else {
  350. OPENSSL_PUT_ERROR(SSL, SSL_R_BAD_SSL_FILETYPE);
  351. goto end;
  352. }
  353. if (x == NULL) {
  354. OPENSSL_PUT_ERROR(SSL, reason_code);
  355. goto end;
  356. }
  357. ret = SSL_CTX_use_certificate(ctx, x);
  358. end:
  359. X509_free(x);
  360. BIO_free(in);
  361. return ret;
  362. }
  363. int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type) {
  364. int reason_code, ret = 0;
  365. BIO *in;
  366. RSA *rsa = NULL;
  367. in = BIO_new(BIO_s_file());
  368. if (in == NULL) {
  369. OPENSSL_PUT_ERROR(SSL, ERR_R_BUF_LIB);
  370. goto end;
  371. }
  372. if (BIO_read_filename(in, file) <= 0) {
  373. OPENSSL_PUT_ERROR(SSL, ERR_R_SYS_LIB);
  374. goto end;
  375. }
  376. if (type == SSL_FILETYPE_ASN1) {
  377. reason_code = ERR_R_ASN1_LIB;
  378. rsa = d2i_RSAPrivateKey_bio(in, NULL);
  379. } else if (type == SSL_FILETYPE_PEM) {
  380. reason_code = ERR_R_PEM_LIB;
  381. rsa = PEM_read_bio_RSAPrivateKey(in, NULL, ctx->default_passwd_callback,
  382. ctx->default_passwd_callback_userdata);
  383. } else {
  384. OPENSSL_PUT_ERROR(SSL, SSL_R_BAD_SSL_FILETYPE);
  385. goto end;
  386. }
  387. if (rsa == NULL) {
  388. OPENSSL_PUT_ERROR(SSL, reason_code);
  389. goto end;
  390. }
  391. ret = SSL_CTX_use_RSAPrivateKey(ctx, rsa);
  392. RSA_free(rsa);
  393. end:
  394. BIO_free(in);
  395. return ret;
  396. }
  397. int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type) {
  398. int reason_code, ret = 0;
  399. BIO *in;
  400. EVP_PKEY *pkey = NULL;
  401. in = BIO_new(BIO_s_file());
  402. if (in == NULL) {
  403. OPENSSL_PUT_ERROR(SSL, ERR_R_BUF_LIB);
  404. goto end;
  405. }
  406. if (BIO_read_filename(in, file) <= 0) {
  407. OPENSSL_PUT_ERROR(SSL, ERR_R_SYS_LIB);
  408. goto end;
  409. }
  410. if (type == SSL_FILETYPE_PEM) {
  411. reason_code = ERR_R_PEM_LIB;
  412. pkey = PEM_read_bio_PrivateKey(in, NULL, ctx->default_passwd_callback,
  413. ctx->default_passwd_callback_userdata);
  414. } else if (type == SSL_FILETYPE_ASN1) {
  415. reason_code = ERR_R_ASN1_LIB;
  416. pkey = d2i_PrivateKey_bio(in, NULL);
  417. } else {
  418. OPENSSL_PUT_ERROR(SSL, SSL_R_BAD_SSL_FILETYPE);
  419. goto end;
  420. }
  421. if (pkey == NULL) {
  422. OPENSSL_PUT_ERROR(SSL, reason_code);
  423. goto end;
  424. }
  425. ret = SSL_CTX_use_PrivateKey(ctx, pkey);
  426. EVP_PKEY_free(pkey);
  427. end:
  428. BIO_free(in);
  429. return ret;
  430. }
  431. /* Read a file that contains our certificate in "PEM" format, possibly followed
  432. * by a sequence of CA certificates that should be sent to the peer in the
  433. * Certificate message. */
  434. int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file) {
  435. BIO *in;
  436. int ret = 0;
  437. X509 *x = NULL;
  438. ERR_clear_error(); /* clear error stack for SSL_CTX_use_certificate() */
  439. in = BIO_new(BIO_s_file());
  440. if (in == NULL) {
  441. OPENSSL_PUT_ERROR(SSL, ERR_R_BUF_LIB);
  442. goto end;
  443. }
  444. if (BIO_read_filename(in, file) <= 0) {
  445. OPENSSL_PUT_ERROR(SSL, ERR_R_SYS_LIB);
  446. goto end;
  447. }
  448. x = PEM_read_bio_X509_AUX(in, NULL, ctx->default_passwd_callback,
  449. ctx->default_passwd_callback_userdata);
  450. if (x == NULL) {
  451. OPENSSL_PUT_ERROR(SSL, ERR_R_PEM_LIB);
  452. goto end;
  453. }
  454. ret = SSL_CTX_use_certificate(ctx, x);
  455. if (ERR_peek_error() != 0) {
  456. ret = 0; /* Key/certificate mismatch doesn't imply ret==0 ... */
  457. }
  458. if (ret) {
  459. /* If we could set up our certificate, now proceed to the CA
  460. * certificates. */
  461. X509 *ca;
  462. int r;
  463. uint32_t err;
  464. SSL_CTX_clear_chain_certs(ctx);
  465. while ((ca = PEM_read_bio_X509(in, NULL, ctx->default_passwd_callback,
  466. ctx->default_passwd_callback_userdata)) !=
  467. NULL) {
  468. r = SSL_CTX_add0_chain_cert(ctx, ca);
  469. if (!r) {
  470. X509_free(ca);
  471. ret = 0;
  472. goto end;
  473. }
  474. /* Note that we must not free r if it was successfully added to the chain
  475. * (while we must free the main certificate, since its reference count is
  476. * increased by SSL_CTX_use_certificate). */
  477. }
  478. /* When the while loop ends, it's usually just EOF. */
  479. err = ERR_peek_last_error();
  480. if (ERR_GET_LIB(err) == ERR_LIB_PEM &&
  481. ERR_GET_REASON(err) == PEM_R_NO_START_LINE) {
  482. ERR_clear_error();
  483. } else {
  484. ret = 0; /* some real error */
  485. }
  486. }
  487. end:
  488. X509_free(x);
  489. BIO_free(in);
  490. return ret;
  491. }
  492. void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb) {
  493. ctx->default_passwd_callback = cb;
  494. }
  495. void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *data) {
  496. ctx->default_passwd_callback_userdata = data;
  497. }
  498. SSL_SESSION *d2i_SSL_SESSION_bio(BIO *bio, SSL_SESSION **out) {
  499. return ASN1_d2i_bio_of(SSL_SESSION, SSL_SESSION_new, d2i_SSL_SESSION, bio,
  500. out);
  501. }
  502. int i2d_SSL_SESSION_bio(BIO *bio, const SSL_SESSION *session) {
  503. return ASN1_i2d_bio_of(SSL_SESSION, i2d_SSL_SESSION, bio, session);
  504. }
  505. IMPLEMENT_PEM_rw(SSL_SESSION, SSL_SESSION, PEM_STRING_SSL_SESSION, SSL_SESSION)